Question
How to write a pandas dataframe to a file and when it is used?

Answer

When you have done your data munging and manipulation with Pandas, you might want to export the DataFrame to another format. This section will cover two ways of outputting your DataFrame: to a CSV or to an Excel file.

Outputting a DataFrame to CSV To output a Pandas DataFrame as a CSV file, you can use to_csv().

Need a full question paper?

Generate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.

Start Generating Free

Similar questions

Consider the following table Bank.

Table: Bank

AccNo Cust_name FD_Amount Months Int_Rate FD_Date
1001 Arti Gupta 30000 36 6.00 2018-07-01
1002 Dilip Lal 50000 48 6.75 2018-03-22
1003 Navin Gupta 30000 36 NULL 2018-03-01
1004 D.P. Yadav 80000 60 8.25 2017-06-12
1005 Jyoti Sharma 20000 36 6.50 2017-01-31
1006 Rakesh Kumar 70000 60 8.25 2018-06-15
1007 K.D. Singh 50000 48 NULL 2018-07-05
1008 Anjali Sharma 60000 48 6.75 2017-04-02
1009 Swati Garg 40000 42 6.50 2018-06-15
1010 Rupinder Kaur 25000 36 6.50 2018-09-27

Write SQL commands for the statements (a) to (h) on the table Bank
(a) Display the details of all FD whose rate of interest is in the range 6% to 7%.
(b) Display the Customer Name and FD Amount for all the loans for which the number of Months is 24, 36, or 48(using IN operator).
(c) Display the Account Number, Customer Name and FD Amount for all the FD for which the Customer Name
ends with “Sharma”.
(d) Delete the records of “Rupinder Kaur”.
(e) Add another column Maturity_Amt of type Integer in the Bank table.
(f) To find the average FD amount. Label the column as “Average FD Amount”.
(g) To find the total FD amount which started in the year 2018?
(h) Update Maturity Amount of all bank customers.
a. Maturity Amount = (FD_Amount*Months* Int_rate)/(12*100)

Write a function to read the content from the "quotes.txt" and transfer the content to the file "Duplicate.txt" but while transfer all the upper case character to lower case character, lower case character to uppercase character and rest of the character as it is.
Answer the following questions based on the given script/code.

(a) Name local variable(s).
(b) Name global variable(s).
(c) __________ is built-in function.
(d) ______________ is user-defined function.

(e) Name actual parameter(s).
(f) Name formal parameter(s).

Write the output produced by the following SQL commands:

Give two examples of PAN and LAN type of networks.     
Write two advantages of 3G over 2G Mobile Telecommunication Technologies in terms of speed and services. 
What is the basic difference between Trojan Horse and Computer Worm? 
What do you mean by authorisation and authentication?
How to iterate over a Pandas DataFrame?
Write a script to create a list of 10 integers and then
(a) Display all the elements of the list
(b) Display the odd elements of the list