Skip to main content

Posts

Showing posts with the label Use above dataframe and do the following:

ads1

3.Use above dataframe and do the following:

Change the DataFrame Sales such that it becomes its transpose. Display the sales made by all sales persons in the year 2018. Display the sales made by Kapil and Mohini in the year 2019 and 2020. Add data to Sales for salesman Nirali where the sales made are [221, 178, 165, 177, 210] in the years [2018, 2019, 2020, 2021] respectively Delete the data for the year 2018 from the DataFrame Sales. Delete the data for sales man Shikhar from the DataFrame Sales. Change the name of the salesperson Kamini to Rani and Kapil to Anil. Update the sale made by Mohini in 118 to 150 in 2018. import pandas as pd #Creating DataFrame d = {2018:[110,130,115,118],      2019:[205,165,175,190],      2020:[115,206,157,179],      2021:[118,198,183,169]} sales=pd.DataFrame(d,index=['Kapil','Kamini','Shikhar','Mohini']) print("Transpose:") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print(sales.T) print("\nSales made by each salesman in 2018") #Method 1

ads2