删除没有标题和数据的列

时间:2018-08-15 08:59:54

标签: python pandas csv dataframe

我有一个CSV文件,当我将其作为数据帧带到python时,它会在数据帧中创建一个新的Unnamed:1列。所以我怎么能删除它或过滤它。 Here, whats my csv looks like

因此,我只需要数据框中的“标题和日期”列,而不需要csv的B列。数据框看起来像

                                               Title  Unnamed: 1        Date
0  Đồng Nai Province makes it easier for people w...         NaN  18/07/2018
1  Ex-NBA forward Washington gets six-year prison...         NaN  10/07/2018
2                                Helicobacter pylori         NaN  10/07/2018
3     Paedophile gets prison term for sexual assault         NaN  03/07/2018
4                  Immunodeficiency burdens families         NaN  28/06/2018

1 个答案:

答案 0 :(得分:1)

从数据框中删除该列:

df.drop(["Unnamed: 1"], inplace=True)