asssign specific sheet in excel to dataframe code example
Example 1: how to read multiple worksheet from a single workbook in column in python
import pandas as pd
def read_excel_sheets(xls_path):
"""Read all sheets of an Excel workbook and return a single DataFrame"""
print(f'Loading {xls_path} into pandas')
xl = pd.ExcelFile(xls_path)
df = pd.DataFrame()
columns = None
for idx, name in enumerate(xl.sheet_names):
print(f'Reading sheet #{idx}: {name}')
sheet = xl.parse(name)
if idx == 0:
columns = sheet.columns
sheet.columns = columns
df = df.append(sheet, ignore_index=True)
return df
Example 2: how to read multiple worksheet from a single workbook in column in python
stops.to_csv("data/stops.01end.csv", index=False)