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
CLN: remove uneeded code in internals; use split_and_operate when possible
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.21.0.txt
+60-8
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,65 @@ the target. Now, a ``ValueError`` will be raised when such an input is passed in
127
127
...
128
128
ValueError: Cannot operate inplace if there is no assignment
129
129
130
+
.. _whatsnew_0210.dtype_conversions:
131
+
132
+
Dtype Conversions
133
+
^^^^^^^^^^^^^^^^^
134
+
135
+
- Previously assignments, ``.where()`` and ``.fillna()`` with a ``bool`` assignment, would coerce to
136
+
same type (e.g. int / float), or raise for datetimelikes. These will now preseve the bools with ``object`` dtypes. (:issue:`16821`).
137
+
138
+
.. ipython:: python
139
+
140
+
s = Series([1, 2, 3])
141
+
142
+
.. code-block:: python
143
+
144
+
In [5]: s[1] = True
145
+
146
+
In [6]: s
147
+
Out[6]:
148
+
0 1
149
+
1 1
150
+
2 3
151
+
dtype: int64
152
+
153
+
New Behavior
154
+
155
+
.. ipython:: python
156
+
157
+
s[1] = True
158
+
s
159
+
160
+
- Previously as assignment to a datetimelike with a non-datetimelike would coerce the
161
+
non-datetime-like item being assigned (:issue:`14145`).
162
+
163
+
.. ipython:: python
164
+
165
+
s = pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2012-01-01')])
166
+
167
+
.. code-block:: python
168
+
169
+
In [1]: s[1] = 1
170
+
171
+
In [2]: s
172
+
Out[2]:
173
+
0 2011-01-01 00:00:00.000000000
174
+
1 1970-01-01 00:00:00.000000001
175
+
dtype: datetime64[ns]
176
+
177
+
These now coerce to ``object`` dtype.
178
+
179
+
.. ipython:: python
180
+
181
+
s[1] = 1
182
+
s
183
+
184
+
- Additional bug fixes w.r.t. dtype conversions.
185
+
186
+
- Inconsistent behavior in ``.where()`` with datetimelikes which would raise rather than coerce to ``object`` (:issue:`16402`)
187
+
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
188
+
130
189
.. _whatsnew_0210.api:
131
190
132
191
Other API Changes
@@ -142,13 +201,6 @@ Other API Changes
142
201
- 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`)
143
202
- ``Index.get_indexer_non_unique()`` now returns a ndarray indexer rather than an ``Index``; this is consistent with ``Index.get_indexer()`` (:issue:`16819`)
144
203
- Removed the ``@slow`` decorator from ``pandas.util.testing``, which caused issues for some downstream packages' test suites. Use ``@pytest.mark.slow`` instead, which achieves the same thing (:issue:`16850`)
145
-
146
-
147
-
.. _whatsnew_0210.api:
148
-
149
-
Other API Changes
150
-
^^^^^^^^^^^^^^^^^
151
-
152
204
- Moved definition of ``MergeError`` to the ``pandas.errors`` module.
153
205
154
206
@@ -192,7 +244,7 @@ Bug Fixes
192
244
Conversion
193
245
^^^^^^^^^^
194
246
195
-
- Bug in assignment against datetime-like data with ``int`` may incorrectly converted to datetime-like (:issue:`14145`)
247
+
- Bug in assignment against datetime-like data with ``int`` may incorrectly converte to datetime-like (:issue:`14145`)
196
248
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
0 commit comments