Align should consider the dtype when creating new columns #31874
Labels
API Design
Dtype Conversions
Unexpected or buggy dtype conversions
Enhancement
Needs Discussion
Requires discussion from core team before further action
Currently when you align columns and create a new column, align will create a new float64 column filled with NaNs.
I think it'd be more useful for the dtypes of new columns to be the same as the dtype from the other.
The newly created
B
column has dtypedatetime64[ns]
, the same asa.B
.This proposal would make the
fill_value
keyword a bit more complex.np.nan
would change toNone
, which means "the right NA value for the dtype".I think this would make the workaround in #31679 unnecessary, as we'd have the correct dtype going into the operation.
If we think this is a good idea, it's probably an API breaking change. We might be able to deprecate this cleanly by (ab)using
fill_value
. We would warn when creating new columns.Unfortunately, that'll happen in the background during binops. Not sure how to get around that, aside from instructing users to explicitly align first.
The text was updated successfully, but these errors were encountered: