thieba11
thieba11

Reputation: 21

How to get the number of columns in a dataset in python

A rookie question here. I am trying to get the number of instances and the number of features in a dataset. I am using pycharm But I am getting an error: (569, 31) [Problem 0-B]: Value should be 32, found 31

def dimensions(dataset_id , dataset):
    dim = None
    num_inst = len(dataset)
    num_feat = len(dataset.columns)
    dim = (num_inst , num_feat)
    print(dim)

    return dim

Upvotes: 0

Views: 78

Answers (1)

Abercrombie
Abercrombie

Reputation: 1086

use dataset.shape instead

def dimensions(dataset_id , dataset):
    return dataset.shape

Upvotes: 1

Related Questions