【问题标题】:Pandas read_table using wrong column as indexPandas read_table 使用错误的列作为索引
【发布时间】:2014-09-10 03:27:39
【问题描述】:

我正在尝试为由制表符分隔的 url 创建一个数据框。但是,pandas 使用行业代码列作为索引。

dff = pd.read_table('http://download.bls.gov/pub/time.series/ce/ce.industry')

会输出

    industry_code   naics_code  publishing_status   industry_name   display_level   selectable  sort_sequence
0    -   B   Total nonfarm   0   T   1  NaN
5000000  -   A   Total private   1   T   2  NaN
6000000  -   A   Goods-producing     1   T   3  NaN
7000000  -   B   Service-providing   1   T   4  NaN
8000000  -   A   Private service-providing   1   T   5  NaN

【问题讨论】:

    标签: python-2.7 pandas indexing dataframe


    【解决方案1】:

    简单!

    table_location = 'http://download.bls.gov/pub/time.series/ce/ce.industry'
    dff = pd.read_table(table_location, index_col=False)
    

    【讨论】:

      猜你喜欢
      • 2017-09-11
      • 2022-07-12
      • 2019-01-21
      • 1970-01-01
      • 2012-12-06
      • 2017-05-23
      • 2016-06-25
      • 2018-02-07
      • 1970-01-01
      相关资源
      最近更新 更多