command description
0 aaa ikegroup WORD Name of the IKE group
1 aaa ikegroup <cr>
0 aaa locald trace Show trace data for the locald component(cisco...
0 aaa login trace Show trace data for login sub system
0 aaa password-policy statistics Show statistics related to password policy
1 aaa password-policy WORD Name of the Password Policy上面是我的数据文件的样子。我想去掉包含数字的第一列,而不是command列。然而,当我这样做时:
df2 = df.drop([df.columns[0]], axis='columns')
这将删除command列,而不是带有索引的列。
我怎么才能放弃第一个呢?
发布于 2019-08-07 20:56:40
你的第一栏只是你的索引。你可以把它藏在你的笔记本里
df.style.hide_index()但不确定这是否带来了很大价值。
如果您正在写入一个文件(例如to_csv),则可以始终将index=False设置为忽略它,例如
df.to_csv('file.csv', index=False)发布于 2019-08-07 21:31:27
还可以将任何列指定为索引:
df.set_index('command', inplace=True)其他有用的命令:
# reset the index
df.reset_index(inplace=True, drop=True)
# sort by index
df.sort_index(inplace=True)https://stackoverflow.com/questions/57402177
复制相似问题