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
@@ -103,6 +103,63 @@ the target. Now, a ``ValueError`` will be raised when such an input is passed in
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
- 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`)
105
105
106
+
.. _whatsnew_0210.dtype_conversions:
107
+
108
+
Dtype Conversions
109
+
^^^^^^^^^^^^^^^^^
110
+
111
+
- Previously assignments, ``.where()`` and ``.fillna()`` with a ``bool`` assignment, would coerce to
112
+
same type (e.g. int / float), or raise for datetimelikes. These will now preseve the bools with ``object`` dtypes. (:issue:`16821`).
113
+
114
+
.. ipython:: python
115
+
116
+
s = Series([1, 2, 3])
117
+
118
+
.. code-block:: python
119
+
120
+
In [5]: s[1] = True
121
+
122
+
In [6]: s
123
+
Out[6]:
124
+
0 1
125
+
1 1
126
+
2 3
127
+
dtype: int64
128
+
129
+
New Behavior
130
+
131
+
.. ipython:: python
132
+
133
+
s[1] = True
134
+
s
135
+
136
+
- Previously as assignment to a datetimelike with a non-datetimelike would corece (:issue:`14145`).
137
+
138
+
.. ipython:: python
139
+
140
+
s = pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2012-01-01')])
141
+
142
+
.. code-block:: python
143
+
144
+
In [1]: s[1] = 1
145
+
146
+
In [2]: s
147
+
Out[2]:
148
+
0 2011-01-01 00:00:00.000000000
149
+
1 1970-01-01 00:00:00.000000001
150
+
dtype: datetime64[ns]
151
+
152
+
These now coerce to ``object`` dtype.
153
+
154
+
.. ipython:: python
155
+
156
+
s[1] = 1
157
+
s
158
+
159
+
- Additional bug fixes w.r.t. dtype conversions.
160
+
161
+
- Inconsistent behavior in ``.where()`` with datetimelikes which would raise rather than coerce to ``object`` (:issue:`16402`)
162
+
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
0 commit comments