I imported a csv file in python. Then, I changed the first column to datetime format.
datetime Bid32 Ask32
2019-01-01 22:06:11.699 1.14587 1.14727
2019-01-01 22:06:12.634 1.14567 1.14707
2019-01-01 22:06:13.091 1.14507 1.14647
I saw three ways for indexing first column.
df.index = df.datetime
del datetime
or
df.set_index('datetime', inplace=True)
and
df.set_index(pd.DatetimeIndex('datetime'), inplace=True)
My question is about the second and third ways. Why in some sources they used pd.DatetimeIndex()
with df.set_index()
(like third code) while the second code was enough?