What Changes Type Of Date In This Pandas Code?
I have a data frame in Pandas that has dates and some other data. The dates are explicitly of type datetime.date. For the example, I'm forcing that by hand. In the real problem,
Solution 1:
I struggled with this for hours and finally traced the issue to the multi-index. In the original context, it was hard to spot because the multi-index operation appeared in the middle of larger set of operations that included slicing, partial indexing, etc. But the bottom line is that the type of the dates is converted at line 4 in the example above when the multi-index is set, and it remains of the Pandas class after that.
If instead I just set_index('time')
, e.g. a regular (not multi) index, there's no type conversion. This was also a complicating factor in tracing the cause since I simplified the indexing operations as a first step in debugging, which eliminated the issue that I was trying to trace.
Post a Comment for "What Changes Type Of Date In This Pandas Code?"