Wednesday, August 9, 2023

Q3)Create the following DataFrame Sales containing year wise sales figures for five salespersons in INR. Use the years as column labels, and salesperson names as row labels.

import pandas as pd

 

# Create the DataFrame

data = {

    2018: [110, 130, 115, 118],

    2019: [205, 165, 206, 198],

    2020: [177, 175, 157, 183],

    2021: [189, 190, 179, 169]

}

 

salespersons = ["Kapil", "Kamini", "Shikhar", "Mohini"]

 

sales_df = pd.DataFrame(data, index=salespersons)

 

# Display row labels

print("Row Labels:")

print(sales_df.index)

 

# Display column labels

print("\nColumn Labels:")

print(sales_df.columns)

 

# Display data types of each column

print("\nData Types:")

print(sales_df.dtypes)

No comments:

Post a Comment