熊猫如何降低等级和列

时间:2018-03-26 18:48:53

标签: python pandas dataframe geopandas

如何删除列上的关卡并删除除“城市”和“几何体”之外的所有列

             AREA  AA5000  HOLD  LEVEL  TYPE   ID  TAZCE10_N                                           geometry
City                                                                                                                    
Detroit  0.120861     2.0     1.0       5.0       0.0  1.0     1101.0  (POLYGON ((-83.47904699999999 41.706103, -83.4...
Austin        NaN     NaN     NaN       NaN       NaN  NaN        NaN  (POLYGON ((-97.577304 29.610979, -97.580744999...

所以它看起来像这样:

City      geometry                                                                                                                
Detroit  (POLYGON ((-83.47904699999999 41.706103, -83.4...
Austin   (POLYGON ((-97.577304 29.610979, -97.580744999...

从技术上讲,这是一个地理因素,我暂时转换为正常的df,因为geopandas没有droplevel()。我已经尝试了下面的语句但它们不起作用并且droplevel抛出错误“AttributeError:'Index'对象没有属性'droplevel'。

    df.columns = [c[-1] for c in df.columns]
    df.reset_index()
    df.columns.droplevel()

1 个答案:

答案 0 :(得分:1)

您可以使用end_date

尝试dropna
thresh