Answers for "pandas data frame from part of excel openpyxl"

0

pandas data frame from part of excel openpyxl

from openpyxl import load_workbook

wb = load_workbook(filename='data.xlsx', 
                   read_only=True)

ws = wb['Sheet2']

# Read the cell values into a list of lists
data_rows = []
for row in ws['A3':'D20']:
    data_cols = []
    for cell in row:
        data_cols.append(cell.value)
    data_rows.append(data_cols)

# Transform into dataframe
import pandas as pd
df = pd.DataFrame(data_rows)
Posted by: Guest on July-14-2021

Code answers related to "pandas data frame from part of excel openpyxl"

Browse Popular Code Answers by Language