1import pandas as pd
2pandas.read_excel(io, sheet_name=0, header=0, names=None,
3 index_col=None, usecols=None,
4 squeeze=False, dtype=None, engine=None,
5 converters=None, true_values=None,
6 false_values=None, skiprows=None,
7 nrows=None, na_values=None,
8 keep_default_na=True, verbose=False,
9 parse_dates=False, date_parser=None,
10 thousands=None, comment=None,
11 skipfooter=0, convert_float=True,
12 mangle_dupe_cols=True, **kwds)
13
14# Example
15pd.read_excel('tmp.xlsx', index_col=0)
1import pandas as pd
2
3sheet1, sheet2 = None, None
4with pd.ExcelFile("PATH\FileName.xlsx") as reader:
5 sheet1 = pd.read_excel(reader, sheet_name='Sheet1')
6 sheet2 = pd.read_excel(reader, sheet_name='Sheet2')
1import pandas as pd
2
3# reading in from external file
4movies = pd.read_excel('movies.xls')
5
6# prints first five rows
7movies.head(n=5)
8# prints last five rows
9movies.tail(n=5)
10
11# for excel files w/ multiple sheets
12movies_sheet1 = pd.read_excel(excel_file, sheetname=0)
13movies_sheet2 = pd.read_excel(excel_file, sheetname=1)
14movies_sheet2 = pd.read_excel(excel_file, sheetname='name of third sheet')
15
16# sort by column
17sorted_by_gross = movies.sort_values(['Gross Earnings'], ascending=False)
18
19# exporting to file
20movies.to_excel('output.xlsx')
1import sqlite3
2import pandas as pd
3from sqlalchemy import create_engine
4
5# Read Excel file or sheets using pandas
6
7# Setup code :)
8
9file = "location of Excel file..."
10
11engine = create_engine('sqlite://', echo=False)
12df = pd.read_excel(file, sheet_name=sheetname)
13df.to_sql("test", engine, if_exists="replace", index=False)
14results = engine.execute("Select * from test")
15final = pd.DataFrame(results, columns=df.columns)