May-25-2021, 05:11 PM
(This post was last modified: Jun-15-2021, 09:35 AM by ju21878436312.)
I would like to write only a few rows from a dataframe into an Excel file.
Is this possible directly when writing or do I have to define a new variable first?
Is this possible directly when writing or do I have to define a new variable first?
import pandas as pd import numpy as np d = {'col1': [1,2,3,4,5,6], 'col2': [1,2,3,4,5,6]} df = pd.DataFrame(data=d) df with pd.ExcelWriter('minimal_to_excel.xlsx') as writer: df.to_excel(writer, startrow=1, sheet_name='row_1_to_3')