zoukankan      html  css  js  c++  java
  • pandas.read_csv 参数 index_col=0

    index_col : int or sequence or False, default None

    用作行索引的列编号或者列名,如果给定一个序列则有多个行索引。
    如果文件不规则,行尾有分隔符,则可以设定index_col=False 来使得pandas不使用第一列作为行索引。
     
    如:
    train_df = pd.read_csv('./input/train.csv')
    print train_df.columns
    结果:

    Index([u'Id', u'MSSubClass', u'MSZoning', u'LotFrontage', u'LotArea',
    u'Street', u'Alley', u'LotShape', u'LandContour', u'Utilities',
    u'LotConfig', u'LandSlope', u'Neighborhood', u'Condition1',
    u'Condition2', u'BldgType', u'HouseStyle', u'OverallQual',
    u'OverallCond', u'YearBuilt', u'YearRemodAdd', u'RoofStyle',
    u'RoofMatl', u'Exterior1st', u'Exterior2nd', u'MasVnrType',。。。]

    train_df = pd.read_csv('./input/train.csv', index_col=0)
    结果:

    Index([u'MSSubClass', u'MSZoning', u'LotFrontage', u'LotArea', u'Street',
    u'Alley', u'LotShape', u'LandContour', u'Utilities', u'LotConfig',
    u'LandSlope', u'Neighborhood', u'Condition1', u'Condition2',
    u'BldgType', u'HouseStyle', u'OverallQual', u'OverallCond',
    u'YearBuilt', u'YearRemodAdd', u'RoofStyle', u'RoofMatl',
    u'Exterior1st', u'Exterior2nd', u'MasVnrType',。。。]



  • 相关阅读:
    Hackerrank--Savita And Friends(最小直径生成树MDST)
    Hackerrank--Kundu and Tree
    Hackerrank--String Function Calculation(后缀数组)
    Hackerrank--Ashton and String(后缀数组)
    Foundation 学习
    JS 严格模式
    判断移动设备横竖屏
    Nodejs解析HTML网页模块 jsdom
    百度Map调用
    Jade 报错
  • 原文地址:https://www.cnblogs.com/TMatrix52/p/7717756.html
Copyright © 2011-2022 走看看