Page 222 - AI_Ver_3.0_class_11
P. 222
Output:
Original DataFrame:
Name Age Address Qualification
0 Adit 27.0 Delhi M.Sc.
1 Ekam NaN Kanpur MA
2 Sakshi 25.0 NaN MCA
3 Anu 30.0 Indore Ph.D.
Missing values in each column:
Name 0
Age 1
Address 1
Qualification 0
dtype: int64
Total number of NaN values:
2
DataFrame after dropping rows with NaN values:
Name Age Address Qualification
0 Adit 27.0 Delhi M.Sc.
3 Anu 30.0 Indore Ph.D.
DataFrame after filling NaN values:
Name Age Address Qualification
0 Adit 27.0 Delhi M.Sc.
1 Ekam 27.0 Kanpur MA
2 Sakshi 25.0 Chennai MCA
3 Anu 30.0 Indore Ph.D.
Attributes of DataFrames
In Pandas, attributes are properties that describe various aspects of the DataFrame's structure and content. Attributes
do not perform any computation or modification on the data; instead, they provide access to metadata or properties
of the object. They are accessed using dot notation and do not require parentheses to invoke. The syntax for using an
attribute is:
DataFrame_name.attribute
Program 55: To create sample DataFrame to illustrate its common attributes and methods
import pandas as pd
# Create a DataFrame with some product data
data = {
'Product': ['Laptop', 'Tablet', 'Smartphone', 'Monitor'],
'Price': [1000, 500, 800, 300],
'Stock': [50, 150, 200, 100],
220 Touchpad Artificial Intelligence (Ver. 3.0)-XI

