Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
What is the syntax of reading file ,writing file in python.and How to read csv file and excel file in DataFrames(pandas).
df = pd.read_csv('myfile.csv') df = pd.read_excel('myfile.xlsx')
Add a comment
To read:
df = pd.read_excel('filename.xlsx') df = pd.read_csv('filename.csv')
To write:
df.to_csv('filename.csv') df.to_excel('filename.xlsx')
if you just googled "pandas read excel"..
See pandas.read_excel() for Excel and pandas.read_csv() for CSV files.
import pandas as pd df=pd.read_csv('file_name.csv')
this will result into Dataframe.If you want to read a specific column and want output as series.
df=pd.read_csv('file_name.csv',usecols=['col_name'],squeeze=True)
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.