You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API: This fixes a number of inconsistencies and API issues
w.r.t. dtype conversions.
This is a reprise of pandas-dev#14145 & pandas-dev#16408.
This removes some code from the core structures & pushes it to internals,
where the primitives are made more consistent.
This should all us to be a bit more consistent for pandas2 type things.
closespandas-dev#16402
supersedes pandas-dev#14145closespandas-dev#14001
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.21.0.txt
+57
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,63 @@ the target. Now, a ``ValueError`` will be raised when such an input is passed in
102
102
- Compression defaults in HDF stores now follow pytable standards. Default is no compression and if ``complib`` is missing and ``complevel`` > 0 ``zlib`` is used (:issue:`15943`)
103
103
- ``Index.get_indexer_non_unique()`` now returns a ndarray indexer rather than an ``Index``; this is consistent with ``Index.get_indexer()`` (:issue:`16819`)
104
104
105
+
.. _whatsnew_0210.dtype_conversions:
106
+
107
+
Dtype Conversions
108
+
^^^^^^^^^^^^^^^^^
109
+
110
+
- Previously assignments, ``.where()`` and ``.fillna()`` with a ``bool`` assignment, would coerce to
111
+
same type (e.g. int / float), or raise for datetimelikes. These will now preseve the bools with ``object`` dtypes. (:issue:`16821`).
112
+
113
+
.. ipython:: python
114
+
115
+
s = Series([1, 2, 3])
116
+
117
+
.. code-block:: python
118
+
119
+
In [5]: s[1] = True
120
+
121
+
In [6]: s
122
+
Out[6]:
123
+
0 1
124
+
1 1
125
+
2 3
126
+
dtype: int64
127
+
128
+
New Behavior
129
+
130
+
.. ipython:: python
131
+
132
+
s[1] = True
133
+
s
134
+
135
+
- Previously as assignment to a datetimelike with a non-datetimelike would corece (:issue:`14145`).
136
+
137
+
.. ipython:: python
138
+
139
+
s = pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2012-01-01')])
140
+
141
+
.. code-block:: python
142
+
143
+
In [1]: s[1] = 1
144
+
145
+
In [2]: s
146
+
Out[2]:
147
+
0 2011-01-01 00:00:00.000000000
148
+
1 1970-01-01 00:00:00.000000001
149
+
dtype: datetime64[ns]
150
+
151
+
These now coerce to ``object`` dtype.
152
+
153
+
.. ipython:: python
154
+
155
+
s[1] = 1
156
+
s
157
+
158
+
- Additional bug fixes w.r.t. dtype conversions.
159
+
160
+
- Inconsistent behavior in ``.where()`` with datetimelikes which would raise rather than coerce to ``object`` (:issue:`16402`)
161
+
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
0 commit comments