Informatics Practices
Write Python statement to export the DataFrame to a CSV file named data.csv stored at D: drive.
Python Pandas
2 Likes
Answer
DataFrame.to_csv('D:\\data.csv')
Answered By
1 Like
Related Questions
Are the following two statements same ? Why/Why not ?
(i)
pd.read_csv('zoo.csv', sep = ',')
(ii)
pd.read_csv('zoo.csv')
How are following two codes similar or different ? What output will they produce ?
(i)
df = pd.read_csv("data.csv", nrows = 5) print(df)
(ii)
df = pd.read_csv("data.csv") print(df)
What is the difference between following two statements ?
(i)
df.to_sql('houses', con = conn, if_exists = 'replace')
(ii)
df.to_sql('houses', con = conn, if_exists = 'replace', index = False)
Consider following code when conn is the name of established connection to MySQL database.
Cars = {'Brand': ['Alto', 'Zen', 'City', 'Kia'], 'Price': [22000, 25000, 27000, 35000]} df = pd.DataFrame(Cars, columns= ['Brand', 'Price']) df.to_sql('CARS', conn, if_exists = 'replace', index = False)
What will be the output of following query if executed on MySQL ?
SELECT * from CARS ;