Q. Write a Python program to count the number of rows and columns of a dataframe. Sample data:


exam_data = {'name': ["Anastasia', 'Dima', 'Katherine', 'James', 'Emily', Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'], 'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], 'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1], "qualify": ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}

labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

Answer :-

df = pd.DataFrame(exam_data, index = labels)
print('Number of Rows:', len(df))
print('Number of columns:', len(list(df)))

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post