使用错误列作为索引的Pandas read_table

时间:2014-07-18 21:54:50

标签: python-2.7 pandas indexing dataframe

我正在尝试为标签分隔的网址创建数据框。但是,pandas使用industry_code列作为索引。

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

1 个答案:

答案 0 :(得分:2)

容易!

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