Page 343 - Informatics_Practices_Fliipbook_Class12
P. 343
plt.tight_layout()
plt.show()
elif choice == 3:
print('Scatter plot')
yAxis = df['Nameofsportsperson']
xAxis = df['MedalWon']
plt.title('Name of sports person and MedalWon')
plt.ylabel("Name of sports person")
plt.xlabel("MedalWon")
plt.xticks(rotation=0)
plt.ticklabel_format(useOffset=False, axis='x', style='plain')
plt.plot(xAxis,yAxis,"y*")
plt.tight_layout()
plt.show()
elif choice == 4:
mainMenu()
else:
print('Please enter right choice\n')
def deleteData():
df = pd.read_csv('data.csv',names = ['NameofEvent', 'Nameofsportsperson',
'Category', 'MedalWon', 'Cashprize'],skiprows=1)
while(True):
print("1. Delete a Row\n2. Delete a range of rows\n3. Delete a Column\
n4. Delete a range of cols\n5. Return to Main Menu")
choice = int(input("Enter Choice:"))
if choice == 1:
n = int(input("Enter the row number (index) to be deleted:"))
df.drop(n,inplace=True)
print(df)
print("Row with index value",n," has been deleted!!!")
elif choice == 2:
start = int(input("Enter the starting row number (index) to be deleted:"))
end = int(input("enter the ending row number (index) to be deleted:"))
if end > start:
df.drop(df.index[st:end+1],inplace=True)
print(df)
print("Rows from index ",start," to index ",end,"have been deleted!!!")
elif choice == 3:
Project 329

