Q1. Write a program read details such as Item, Sales made in a dataframe and then store this data in a CSV file.

Answer :-

import pandas as pd
n=int(input('enter no of item '))

dic={}
values_sales=[]
values_name=[]
for i in range(n):
    item_n=input('enter name of item')
    sales=int(input('enter sales made of item'))
    values_sales.append(sales)
    values_name.append(item_n)
dic['Name ']=values_name
dic['sales']=values_sales
dframe=pd.DataFrame(dic)
print(dframe)
dframe.to_csv('csv file',sep='|')

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post