pandas .set_index(“TIMESTAMP“, inplace=True) 用法
Posted gz153016
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pandas .set_index(“TIMESTAMP“, inplace=True) 用法相关的知识,希望对你有一定的参考价值。
# -- coding: utf-8 --
import pandas as pd
vehicle_data = pd.read_csv('./my_test.csv')
print('self.vehicle_data:\\n', vehicle_data)
vehicle_data.set_index("TIMESTAMP", inplace=True) #TIMESTAMP를 index로 설정 loc.[x]하면 x타임스탬프 다나옴
# 将TIMESTAMP设置为index loc.[x]表示x时间戳.
print('--self.vehicle_data:\\n', vehicle_data)
sub_data = vehicle_data.loc[1]
print('sub_data:\\n', sub_data)
my_test.csv
ID,TIMESTAMP,SPEED,DIST_1
1,1,29.892414313684153,7900.153590372733
1,2,2.7412789960873742,7883.5784782071405
1,3,36.28131032972068,7807.734948765844
1,4,59.47461142564956,7718.342638157866
2,1,42.43589247100008,7193.28791002723
2,2,23.851346476158845,7248.147840954433
2,3,30.781706270452382,7305.778861716182
2,4,20.766817359882033,7268.85822264047
3,1,24.840682228354417,9133.268969675311
3,2,15.146123179523963,9158.324113488648
3,3,8.212384355842781,9143.682884949692
3,4,1.579423657153851,9136.553190558296
以上是关于pandas .set_index(“TIMESTAMP“, inplace=True) 用法的主要内容,如果未能解决你的问题,请参考以下文章
pandas 中 df.reindex() 和 df.set_index() 方法的区别
pandas set_index() reset_index()
pandas --index ,reindex, set_index, reset_index , reindex_like函数 之 set_index
pandas --index ,reindex, set_index, reset_index , reindex_like函数 之 set_index