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
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v1.4.0.rst
+57-37
Original file line number
Diff line number
Diff line change
@@ -40,55 +40,43 @@ This made it difficult to determine where the warning was being generated from.
40
40
A value is trying to be set on a copy of a slice from a DataFrame.
41
41
42
42
43
-
.. _whatsnew_140.enhancements.numeric_index:
44
43
45
-
More flexible numeric dtypes for indexes
46
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
44
48
-
Until now, it has only been possible to create numeric indexes with int64/float64/uint64 dtypes.
49
-
It is now possible to create an index of any numpy int/uint/float dtype using the new :class:`NumericIndex` index type (:issue:`41153`):
45
+
.. _whatsnew_140.enhancements.ExtensionIndex:
50
46
51
-
.. ipython:: python
47
+
Index can hold arbitrary ExtensionArrays
48
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52
49
53
-
pd.NumericIndex([1, 2, 3], dtype="int8")
54
-
pd.NumericIndex([1, 2, 3], dtype="uint32")
55
-
pd.NumericIndex([1, 2, 3], dtype="float32")
50
+
Until now, passing a custom :class:`ExtensionArray` to ``pd.Index`` would cast the
51
+
array to ``object`` dtype. Now :class:`Index` can directly hold arbitrary ExtensionArrays (:issue:`43930`).
56
52
57
-
In order to maintain backwards compatibility, calls to the base :class:`Index` will currently
58
-
return :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index`, where relevant.
59
-
For example, the code below returns an ``Int64Index`` with dtype ``int64``:
53
+
*Previous behavior*:
60
54
61
-
.. code-block:: ipython
55
+
.. ipython:: python
62
56
63
-
In [1]: pd.Index([1, 2, 3], dtype="int8")
64
-
Int64Index([1, 2, 3], dtype='int64')
57
+
arr =pd.array([1, 2, pd.NA])
58
+
idx = pd.Index(arr)
65
59
66
-
but will in a future version return a :class:`NumericIndex` with dtype ``int8``.
60
+
In the old behavior, ``idx`` would be object-dtype:
67
61
68
-
More generally, currently, all operations that until now have
69
-
returned :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index` will
70
-
continue to so. This means, that in order to use ``NumericIndex`` in the current version, you
71
-
will have to call ``NumericIndex`` explicitly. For example the below series will have an ``Int64Index``:
62
+
*Previous behavior*:
72
63
73
64
.. code-block:: ipython
74
65
75
-
In [2]: ser = pd.Series([1, 2, 3], index=[1, 2, 3])
76
-
In [3]: ser.index
77
-
Int64Index([1, 2, 3], dtype='int64')
66
+
In [1]: idx
67
+
Out[1]: Index([1, 2, <NA>], dtype='object')
78
68
79
-
Instead, if you want to use a ``NumericIndex``, you should do:
69
+
With the new behavior, we keep the original dtype:
80
70
81
-
.. ipython:: python
71
+
*New behavior*:
82
72
83
-
idx = pd.NumericIndex([1, 2, 3], dtype="int8")
84
-
ser = pd.Series([1, 2, 3], index=idx)
85
-
ser.index
73
+
.. ipython:: python
86
74
87
-
In a future version of Pandas, :class:`NumericIndex` will become the default numeric index type and
88
-
``Int64Index``, ``UInt64Index`` and ``Float64Index`` are therefore deprecated and will
89
-
be removed in the future, see :ref:`here <whatsnew_140.deprecations.int64_uint64_float64index>` for more.
75
+
idx
90
76
91
-
See :ref:`here <advanced.numericindex>` for more about :class:`NumericIndex`.
77
+
One exception to this is ``SparseArray``, which will continue to cast to numpy
78
+
dtype until pandas 2.0. At that point it will retain its dtype like other
79
+
ExtensionArrays.
92
80
93
81
.. _whatsnew_140.enhancements.styler:
94
82
@@ -236,7 +224,7 @@ Other enhancements
236
224
- :meth:`is_list_like` now identifies duck-arrays as list-like unless ``.ndim == 0`` (:issue:`35131`)
237
225
- :class:`ExtensionDtype` and :class:`ExtensionArray` are now (de)serialized when exporting a :class:`DataFrame` with :meth:`DataFrame.to_json` using ``orient='table'`` (:issue:`20612`, :issue:`44705`).
238
226
- Add support for `Zstandard <http://facebook.github.io/zstd/>`_ compression to :meth:`DataFrame.to_pickle`/:meth:`read_pickle` and friends (:issue:`43925`)
239
-
-
227
+
-:meth:`DataFrame.to_sql` now returns an ``int`` of the number of written rows (:issue:`23998`)
- Deprecated passing non boolean argument to sort in :func:`concat` (:issue:`41518`)
604
613
- Deprecated passing arguments as positional for :func:`read_fwf` other than ``filepath_or_buffer`` (:issue:`41485`):
605
614
- Deprecated passing ``skipna=None`` for :meth:`DataFrame.mad` and :meth:`Series.mad`, pass ``skipna=True`` instead (:issue:`44580`)
615
+
- Deprecated the behavior of :func:`to_datetime` with the string "now" with ``utc=False``; in a future version this will match ``Timestamp("now")``, which in turn matches :meth:`Timestamp.now` returning the local time (:issue:`18705`)
606
616
- Deprecated :meth:`DateOffset.apply`, use ``offset + other`` instead (:issue:`44522`)
607
617
- Deprecated parameter ``names`` in :meth:`Index.copy` (:issue:`44916`)
608
618
- A deprecation warning is now shown for :meth:`DataFrame.to_latex` indicating the arguments signature may change and emulate more the arguments to :meth:`.Styler.to_latex` in future versions (:issue:`44411`)
@@ -619,8 +629,10 @@ Other Deprecations
619
629
- Deprecated ``numeric_only=None`` in :meth:`DataFrame.rank`; in a future version ``numeric_only`` must be either ``True`` or ``False`` (the default) (:issue:`45036`)
620
630
- Deprecated the behavior of :meth:`Timestamp.utcfromtimestamp`, in the future it will return a timezone-aware UTC :class:`Timestamp` (:issue:`22451`)
621
631
- Deprecated :meth:`NaT.freq` (:issue:`45071`)
632
+
- Deprecated behavior of :class:`Series` and :class:`DataFrame` construction when passed float-dtype data containing ``NaN`` and an integer dtype ignoring the dtype argument; in a future version this will raise (:issue:`40110`)
- Bug in division of all-``NaT`` :class:`TimeDeltaIndex`, :class:`Series` or :class:`DataFrame` column with object-dtype arraylike of numbers failing to infer the result as timedelta64-dtype (:issue:`39750`)
720
732
- Bug in floor division of ``timedelta64[ns]`` data with a scalar returning garbage values (:issue:`44466`)
733
+
- Bug in :class:`Timedelta` now properly taking into account any nanoseconds contribution of any kwarg (:issue:`43764`)
734
+
-
721
735
722
736
Timezones
723
737
^^^^^^^^^
@@ -800,6 +814,7 @@ Indexing
800
814
- Bug in :meth:`IntervalIndex.get_indexer_non_unique` not handling targets of ``dtype`` 'object' with NaNs correctly (:issue:`44482`)
801
815
- Fixed regression where a single column ``np.matrix`` was no longer coerced to a 1d ``np.ndarray`` when added to a :class:`DataFrame` (:issue:`42376`)
802
816
- Bug in :meth:`Series.__getitem__` with a :class:`CategoricalIndex` of integers treating lists of integers as positional indexers, inconsistent with the behavior with a single scalar integer (:issue:`15470`, :issue:`14865`)
817
+
- Bug in :meth:`Series.__setitem__` when setting floats or integers into integer-dtype series failing to upcast when necessary to retain precision (:issue:`45121`)
803
818
-
804
819
805
820
Missing
@@ -870,6 +885,8 @@ Period
870
885
- Bug in :meth:`PeriodIndex.to_timestamp` when the index has ``freq="B"`` inferring ``freq="D"`` for its result instead of ``freq="B"`` (:issue:`44105`)
871
886
- Bug in :class:`Period` constructor incorrectly allowing ``np.timedelta64("NaT")`` (:issue:`44507`)
872
887
- Bug in :meth:`PeriodIndex.to_timestamp` giving incorrect values for indexes with non-contiguous data (:issue:`44100`)
888
+
- Bug in :meth:`Series.where` with ``PeriodDtype`` incorrectly raising when the ``where`` call should not replace anything (:issue:`45135`)
889
+
873
890
-
874
891
875
892
Plotting
@@ -899,6 +916,7 @@ Groupby/resample/rolling
899
916
- Bug in :meth:`GroupBy.nth` failing on ``axis=1`` (:issue:`43926`)
900
917
- Fixed bug in :meth:`Series.rolling` and :meth:`DataFrame.rolling` not respecting right bound on centered datetime-like windows, if the index contain duplicates (:issue:`3944`)
901
918
- Bug in :meth:`Series.rolling` and :meth:`DataFrame.rolling` when using a :class:`pandas.api.indexers.BaseIndexer` subclass that returned unequal start and end arrays would segfault instead of raising a ``ValueError`` (:issue:`44470`)
919
+
- Bug in :meth:`Groupby.nunique` not respecting ``observed=True`` for Categorical grouping columns (:issue:`45128`)
902
920
- Bug in :meth:`GroupBy.head` and :meth:`GroupBy.tail` not dropping groups with ``NaN`` when ``dropna=True`` (:issue:`45089`)
903
921
- Fixed bug in :meth:`GroupBy.__iter__` after selecting a subset of columns in a :class:`GroupBy` object, which returned all columns instead of the chosen subset (:issue:`#44821`)
904
922
- Bug in :meth:`Groupby.rolling` when non-monotonic data passed, fails to correctly raise ``ValueError`` (:issue:`43909`)
@@ -924,6 +942,7 @@ Reshaping
924
942
- Bug in :meth:`Series.unstack` with object doing unwanted type inference on resulting columns (:issue:`44595`)
925
943
- Bug in :class:`MultiIndex` failing join operations with overlapping ``IntervalIndex`` levels (:issue:`44096`)
926
944
- Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` results is different ``dtype`` based on ``regex`` parameter (:issue:`44864`)
945
+
- Bug in :meth:`DataFrame.pivot` with ``index=None`` when the :class:`DataFrame` index was a :class:`MultiIndex` (:issue:`23955`)
927
946
928
947
Sparse
929
948
^^^^^^
@@ -940,6 +959,7 @@ ExtensionArray
940
959
- Bug in :func:`array` failing to preserve :class:`PandasArray` (:issue:`43887`)
941
960
- NumPy ufuncs ``np.abs``, ``np.positive``, ``np.negative`` now correctly preserve dtype when called on ExtensionArrays that implement ``__abs__, __pos__, __neg__``, respectively. In particular this is fixed for :class:`TimedeltaArray` (:issue:`43899`, :issue:`23316`)
942
961
- NumPy ufuncs ``np.minimum.reduce`` ``np.maximum.reduce``, ``np.add.reduce``, and ``np.prod.reduce`` now work correctly instead of raising ``NotImplementedError`` on :class:`Series` with ``IntegerDtype`` or ``FloatDtype`` (:issue:`43923`, :issue:`44793`)
962
+
- NumPy ufuncs with ``out`` keyword are now supported by arrays with ``IntegerDtype`` and ``FloatingDtype`` (:issue:`45122`)
943
963
- Avoid raising ``PerformanceWarning`` about fragmented DataFrame when using many columns with an extension dtype (:issue:`44098`)
944
964
- Bug in :class:`IntegerArray` and :class:`FloatingArray` construction incorrectly coercing mismatched NA values (e.g. ``np.timedelta64("NaT")``) to numeric NA (:issue:`44514`)
945
965
- Bug in :meth:`BooleanArray.__eq__` and :meth:`BooleanArray.__ne__` raising ``TypeError`` on comparison with an incompatible type (like a string). This caused :meth:`DataFrame.replace` to sometimes raise a ``TypeError`` if a nullable boolean column was included (:issue:`44499`)
0 commit comments