disable index pandas data frame

前端 未结 5 1469
既然无缘
既然无缘 2021-02-05 05:04

How can I drop or disable the indices in a pandas Data Frame?

I am learning the pandas from the book \"python for data analysis\" and I already know I can use the datafr

5条回答
  •  太阳男子
    2021-02-05 05:33

    Additionally, if you are using the df.to_excel function of a pd.ExcelWriter, which is where it is written to an Excel worksheet, you can specify index=False in your parameters there.

    create the Excel writer:

    writer = pd.ExcelWriter(type_box + '-rules_output-' + date_string + '.xlsx',engine='xlsxwriter')  
    

    We have a list called lines:

    # create a dataframe called 'df'
    df = pd.DataFrame([sub.split(",") for sub in lines], columns=["Rule", "Device", "Status"]))
    
    #convert df to Excel worksheet
    df.to_excel(writer, sheet_name='all_status',**index=False**)
    writer.save()
    

提交回复
热议问题