[Python] Python in Excel: How to print output dataframe to a tab

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am experimenting on the new Python in Excel feature. I wrote the following lines in a cell.

    import pandas as pd
    input_df = pd.DataFrame(xl("A6:ASH38", headers=True))
    input_header = list(input_df.columns.values)
    label_col = input_header[:14]
    value_col = input_header[14:]
    output_df = input_df.groupby(label_col)[value_col].sum().reset_index()
    output_df.to_csv('test.csv', index=False)


    However, I cannot see the test.csv file being generated. Moreover, how can I print the output_df to a new tab in the spreadsheet?

    Continue reading...

Compartilhe esta Página