Problem mixing datetime64 with other types in DataFrame column #9336
Labels
Error Reporting
Incorrect or improved errors from pandas
good first issue
Indexing
Related to indexing on series/frames, not to indexes themselves
Milestone
Given a DataFrame with a column of type datetime64, there is a problem assigning values of other types to slice of said column:
in [148]:
It doesn't mind this:
Now try assigning values of a another type:
Now, the problem runs deeper than this. I didn't actually come across it when trying to assign mixed types to a single column. I was actually assigning values to a block of a DataFrame which included the time column. Here is an example:
Note that the following works:
So when using the array A.values, the dtype is forced to object which then causes the problem. However, in the case where A has a different index than df, using A.values is necessary to assign the values. Maybe I need to be more careful but the error message doesn't help and it took me a long time to understand the problem. If I try to assign values to a slice of column 'c' using the corresponding slice of A.values I get a different error, which is more informative:
The text was updated successfully, but these errors were encountered: