Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个熊猫数据框,想删除所有列以保存索引和一个名为“bob”的列
我该怎么做?
你可以简单地写:
df = df[['bob']]
其他列将被垃圾收集。
你可以使用 df.loc 访问器
df=df.loc[:,['bob']]