I am trying to set the dtype on the index of a panda dataframe
import pandas as pd
import numpy as np
a = pd.DataFrame(columns=['value'])
a.loc[np.uint64(3)] = [3]
# Here I would expect to get UINT64 but it's INT64
a.index.dtype
> dtype('int64')
a.index = a.index.astype(np.uint64)
# Works as expected
a.index.dtype
> dtype('uint64')
a.loc[np.uint64(4)] = [4]
# Now I am getting totally confused. Why do I get float64 ?
a.index.dtype
> dtype('float64')
- Why is Panda not using the DType of the index value passed to the lob function
- Why is the dtype changing of what it seems to be randomly ?
What am I missing ? What is the proper way to set the index type once and for all ?