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
@@ -92,6 +92,65 @@ the target. Now, a ``ValueError`` will be raised when such an input is passed in
92
92
...
93
93
ValueError: Cannot operate inplace if there is no assignment
94
94
95
+
.. _whatsnew_0210.dtype_conversions:
96
+
97
+
Dtype Conversions
98
+
^^^^^^^^^^^^^^^^^
99
+
100
+
- Previously assignments, ``.where()`` and ``.fillna()`` with a ``bool`` assignment, would coerce to
101
+
same type (e.g. int / float), or raise for datetimelikes. These will now preseve the bools with ``object`` dtypes. (:issue:`16821`).
102
+
103
+
.. ipython:: python
104
+
105
+
s = Series([1, 2, 3])
106
+
107
+
.. code-block:: python
108
+
109
+
In [5]: s[1] = True
110
+
111
+
In [6]: s
112
+
Out[6]:
113
+
0 1
114
+
1 1
115
+
2 3
116
+
dtype: int64
117
+
118
+
New Behavior
119
+
120
+
.. ipython:: python
121
+
122
+
s[1] = True
123
+
s
124
+
125
+
- Previously as assignment to a datetimelike with a non-datetimelike would coerce the
126
+
non-datetime-like item being assigned (:issue:`14145`).
127
+
128
+
.. ipython:: python
129
+
130
+
s = pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2012-01-01')])
131
+
132
+
.. code-block:: python
133
+
134
+
In [1]: s[1] = 1
135
+
136
+
In [2]: s
137
+
Out[2]:
138
+
0 2011-01-01 00:00:00.000000000
139
+
1 1970-01-01 00:00:00.000000001
140
+
dtype: datetime64[ns]
141
+
142
+
These now coerce to ``object`` dtype.
143
+
144
+
.. ipython:: python
145
+
146
+
s[1] = 1
147
+
s
148
+
149
+
- Additional bug fixes w.r.t. dtype conversions.
150
+
151
+
- Inconsistent behavior in ``.where()`` with datetimelikes which would raise rather than coerce to ``object`` (:issue:`16402`)
152
+
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
153
+
95
154
.. _whatsnew_0210.api:
96
155
97
156
Other API Changes
@@ -107,13 +166,6 @@ Other API Changes
107
166
- 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`)
108
167
- ``Index.get_indexer_non_unique()`` now returns a ndarray indexer rather than an ``Index``; this is consistent with ``Index.get_indexer()`` (:issue:`16819`)
109
168
- 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`)
110
-
111
-
112
-
.. _whatsnew_0210.api:
113
-
114
-
Other API Changes
115
-
^^^^^^^^^^^^^^^^^
116
-
117
169
- Moved definition of ``MergeError`` to the ``pandas.errors`` module.
118
170
119
171
@@ -155,7 +207,7 @@ Bug Fixes
155
207
Conversion
156
208
^^^^^^^^^^
157
209
158
-
- Bug in assignment against datetime-like data with ``int`` may incorrectly converted to datetime-like (:issue:`14145`)
210
+
- Bug in assignment against datetime-like data with ``int`` may incorrectly converte to datetime-like (:issue:`14145`)
159
211
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
0 commit comments