The DataFrame.ndim
attribute in Pandas library returns the number (an int
) representing the number of array dimensions of a given series or DataFrame.
The DataFrame.ndim
attribute takes the following syntax:
DataFrame.ndim
The DataFrame.ndim
being an attribute takes no parameter value.
The DataFrame.ndim
attribute returns an int
value 1
if the input data is series and a value of 2
if otherwise.
import pandas as pd # creating a dataframe a = pd.DataFrame({'AGE': [ 20, 29], 'HEIGHT': [94, 170], 'WEIGHT': [80, 115]}) # creating a series b = pd.Series({'a': 1, 'b': 2, 'c': 3}) # implemnting the DataFrame.ndim attribute print(a.ndim) print(b.ndim)
pandas
module.a
.b
.a
and print the result to the console.b
and print the result to the console.
RELATED TAGS
CONTRIBUTOR
View all Courses