-2

What is the syntax of reading file ,writing file in python.and How to read csv file and excel file in DataFrames(pandas).

Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58
amigana _34
  • 35
  • 1
  • 1
  • 8
  • 4
    Possible duplicate of [Reading an Excel file in python using pandas](https://stackoverflow.com/questions/17063458/reading-an-excel-file-in-python-using-pandas) – snipsnipsnip Nov 06 '18 at 09:36

4 Answers4

2
   df = pd.read_csv('myfile.csv')
   df = pd.read_excel('myfile.xlsx')
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58
1

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"..

dejanmarich
  • 1,235
  • 10
  • 26
1

See pandas.read_excel() for Excel and pandas.read_csv() for CSV files.

iz_
  • 15,923
  • 3
  • 25
  • 40
0
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)
The_Scan_Master
  • 136
  • 1
  • 5