我正在尝试执行以下操作
measurement_df = pd.read_csv('data/tag_measurements/all_measurements.csv')
measurement_df.head(3)
measurement_df
>> prints
. timestamp tag_1 tag_2 tag_3
0 2018-01-01 11:09:00 0.729193 -0.236627 -1.968651
1 2018-01-02 05:56:00 -2.812988 0.394632 -1.151147
2 2018-01-03 00:37:00 0.363185 -0.089076 -1.509133
此时,timestamp列的类型为str:
type(measurement_df.iloc[0]['timestamp'])
>> prints
str
vdf = vx.from_pandas(measurement_df)
vdf.head(3)
>> prints
# tag_1 tag_2 tag_3 index
0 0.7291933972260769 -0.2366268009370677 -1.9686509728501898 0
1 -2.8129876800434737 0.3946317890604529 -1.1511473058592252 1
2 0.3631852302577519 -0.08907562484360453 -1.5091330993605443 2
我以某种方式丢失了时间戳列。任何想法可能出什么问题吗?
答案 0 :(得分:0)
如果您想保留日期/时间格式,尤其是在读取CSV时,我建议您这样做:
df = pd.read_csv('myfile.csv', parse_dates=['datetime_col_1', 'datetime_col_2'])
您也可以这样做:
df = vaex.read_csv('myfile.csv', parse_dates=['datetime_col_1', 'datetime_col_2'])
相同,因为它在后台使用pandas方法。