Page 458 - AI Ver 3.0 class 10_Flipbook
P. 458
• Modifying an existing Row
[1]: f2.loc[33]=['Sneha',95,'C']
print(f2)
Name Marks Section
11 Riya 92 A
22 Sonali 90 E
33 Sneha 95 C
44 Nitin 84 C
• Modifying an existing column
[1]: f2['Marks']=[92,97, 91,89]
print(f2)
Name Marks Section
11 Riya 92 A
22 Sonali 97 E
33 Sneha 91 C
44 Nitin 89 C
• Deleting a Row
To delete a row or a column, the .drop() method is used with the DataFrame. The parameter axis=0 is used for
deleting a row and axis=1 for deleting a column.
[1]: f2=f2.drop(22,axis=0)
print(f2)
Name Marks Section
11 Riya 92 A
33 Sneha 91 C
44 Nitin 89 C
• Deleting a Column
[1]: f2=f2.drop('Marks',axis=1)
print(f2)
Name Section
11 Riya A
33 Sneha C
44 Nitin C
Task 21 st Century #Technology Literacy
Skills
Find out what happens when you add the following statements in a DataFrame created earlier:
a. f2.loc[22]
b. f2[:] = 0
c. f2.loc[33]=0
Python with Pandas is used in a wide range of fields, including academic and commercial domains like finance,
economics, statistics, and analytics. Pandas offers several important features:
• It provides a fast and efficient way to manage and explore data using Series and DataFrames, making it suitable
for data science.
456 Touchpad Artificial Intelligence (Ver. 3.0)-X

