Python pandas HDFstore append dataframe with missing column

206 views Asked by At

Say I already have a hdfstore, having 3 columns [a,b,c] whose dtype are [uint32,int64,datetime64[ns]]

The problem is how to append dataframe with missing column. Say column 'c' is missing, I try to append only [a,b], I cannot do it directly because the dataframe cannot match existing table structure

I try to reindex the dataframe including column 'c', and it still doesn't work, because the new column 'c' is all NaN by default, and its dtype is float64, still doesn't match.

So I try to change its dtype, using .astype(datetime64[ns]) but this method doesn't work on either, the dtype stay unchanged.

Now I am stucked, how can I append this partial column dataframe into HDFstore?

0

There are 0 answers