比方说,我将我的文件导出到 excel 中
声明出口
ln[] = writer = pd.ExcelWriter("df2018.xlsx")
writer = pd.ExcelWriter("df2018.xlsx", index = false)
df2018.to_excel(writer)
writer.save()
out[] =
row0 (blank) kanwil jan 2018 feb 2018 janfeb 2018
row1 0 sunarto 45878 545458 5454878
row2 1 hartanto 123456 545454 4444549
row3 2 pemabuk 9547 787896 4579798
(如果数据框是 df2018)
我的预期:
row0 kanwil jan 2018 feb 2018 janfeb 2018
row1 sunarto 45878 545458 5454878
row2 hartanto 123456 545454 4444549
row3 pemabuk 9547 787896 4579798
我想删除第一列
我试过了
pd.ExcelWriter("df2018.xlsx", index = false)
但它不起作用
如果我在导出 csv 或 excel 时要删除第一列该怎么办
事实上,我从下面的数据框(df2018)中获取信息:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 154 entries, 2 to 155
Data columns (total 5 columns):
Kanwil 149 non-null object
Cabang 137 non-null object
Income Januari 2018 151 non-null object
Income Febuari 2018 151 non-null object
Income Jan-Feb 2018 151 non-null object
dtypes: object(5)
memory usage: 4.2+ KB
None