Python Pandas - DataFrame Attributes
Algorithm:
1. Install Pandas using pip.
2. Import Pandas.
3. Create a DataFrame.
4. Display the DataFrame and its attributes (shape, columns, dtypes, head, describe).
Program:
import pandas as pd
data = {'Name': ['A', 'B'], 'Age': [20, 21]}
df = pd.DataFrame(data)
print(df)
print(df.shape)
print(df.columns)
print(df.dtypes)
print(df.head())
print(df.describe())
Output:
Name Age
0 A 20
1 B 21
(2, 2)
Index(['Name', 'Age'], dtype='object')
Name object
Age int64
dtype: object
Name Age
0 A 20
1 B 21
Age
count 2.000000
mean 20.500000
std 0.707107
min 20.000000
max 21.000000