如何在数据框中设置索引

时间:2019-01-23 08:37:50

标签: python pandas indexing

<class 'pandas.core.frame.DataFrame'>
Int64Index: 157 entries, 18 to 9169
Data columns (total 5 columns):
areaName      157 non-null object
deviceId      157 non-null object
value         157 non-null float64
date          157 non-null datetime64[ns]
difference    157 non-null float64
dtypes: datetime64[ns](1), float64(2), object(2)
memory usage: 7.4+ KB

在此 print(df.info())显示索引为157个条目,但从18开始,以9169结尾。

那么我如何获得157个条目,索引中的0到156

我需要这样:

<class 'pandas.core.frame.DataFrame'>
Int64Index: 157 entries, 0 to 156
Data columns (total 5 columns):
areaName      157 non-null object
deviceId      157 non-null object
value         157 non-null float64
date          157 non-null datetime64[ns]
difference    157 non-null float64
dtypes: datetime64[ns](1), float64(2), object(2)
memory usage: 7.4+ KB

我如何获取或更改熊猫的索引值

0 个答案:

没有答案