8000 Merge remote-tracking branch 'upstream/master' into cython-3-compat · pandas-dev/pandas@f5ed8db · GitHub
[go: up one dir, main page]

Skip to content

Commit f5ed8db

Browse files
committed
Merge remote-tracking branch 'upstream/master' into cython-3-compat
2 parents e5a3669 + 1490d0c commit f5ed8db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+878
-239
lines changed

asv_bench/benchmarks/series_methods.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,25 @@ def time_dropna(self, dtype):
124124
self.s.dropna()
125125

126126

127+
class SearchSorted(object):
128+
129+
goal_time = 0.2
130+
params = ['int8', 'int16', 'int32', 'int64',
131+
'uint8', 'uint16', 'uint32', 'uint64',
132+
'float16', 'float32', 'float64',
133+
'str']
134+
param_names = ['dtype']
135+
136+
def setup(self, dtype):
137+
N = 10**5
138+
data = np.array([1] * N + [2] * N + [3] * N).astype(dtype)
139+
self.s = Series(data)
140+
141+
def time_searchsorted(self, dtype):
142+
key = '2' if dtype == 'str' else 2
143+
self.s.searchsorted(key)
144+
145+
127146
class Map(object):
128147

129148
params = ['dict', 'Series']

ci/deps/azure-27-compat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
- pytest
2222
- pytest-xdist
2323
- pytest-mock
24+
- isort
2425
- pip:
2526
- html5lib==1.0b2
2627
- beautifulsoup4==4.2.1

ci/deps/azure-27-locale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies:
2424
- pytest-xdist
2525
- pytest-mock
2626
- hypothesis>=3.58.0
27+
- isort
2728
- pip:
2829
- html5lib==1.0b2
2930
- beautifulsoup4==4.2.1

ci/deps/azure-36-locale_slow.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ dependencies:
3030
- pytest-xdist
3131
- pytest-mock
3232
- moto
33+
- isort
3334
- pip:
3435
- hypothesis>=3.58.0

ci/deps/azure-37-locale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies:
2828
- pytest
2929
- pytest-xdist
3030
- pytest-mock
31+
- isort
3132
- pip:
3233
- hypothesis>=3.58.0
3334
- moto # latest moto in conda-forge fails with 3.7, move to conda dependencies when this is fixed

ci/deps/azure-37-numpydev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- pytest-xdist
1111
- pytest-mock
1212
- hypothesis>=3.58.0
13+
- isort
1314
- pip:
1415
- "git+git://github.com/dateutil/dateutil.git"
1516
- "-f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com"

ci/deps/azure-macos-35.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies:
2525
- pytest
2626
- pytest-xdist
2727
- pytest-mock
28+
- isort
2829
- pip:
2930
- python-dateutil==2.5.3
3031
- hypothesis>=3.58.0

ci/deps/azure-windows-27.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ dependencies:
3030
- pytest-mock
3131
- moto
3232
- hypothesis>=3.58.0
33+
- isort

ci/deps/azure-windows-36.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ dependencies:
2727
- pytest-xdist
2828
- pytest-mock
2929
- hypothesis>=3.58.0
30+
- isort

ci/deps/travis-27.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies:
4444
- pytest-mock
4545
- moto==1.3.4
4646
- hypothesis>=3.58.0
47+
- isort
4748
- pip:
4849
- backports.lzma
4950
- pandas-gbq

ci/deps/travis-36-doc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ dependencies:
4343
# universal
4444
- pytest
4545
- pytest-xdist
46+
- isort

ci/deps/travis-36-locale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ dependencies:
3232
- pytest-xdist
3333
- pytest-mock
3434
- moto
35+
- isort
3536
- pip:
3637
- hypothesis>=3.58.0

ci/deps/travis-36-slow.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ dependencies:
3030
- pytest-mock
3131
- moto
3232
- hypothesis>=3.58.0
33+
- isort

ci/deps/travis-36.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies:
3838
- pytest-cov
3939
- pytest-mock
4040
- hypothesis>=3.58.0
41+
- isort
4142
- pip:
4243
- brotlipy
4344
- coverage

ci/deps/travis-37.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ dependencies:
1717
- pytest-mock
1818
- hypothesis>=3.58.0
1919
- s3fs
20+
- isort
2021
- pip:
2122
- moto

doc/source/development/extending.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ decorate a class, providing the name of attribute to add. The class's
3333
3434
@staticmethod
3535
def _validate(obj):
36-
if 'lat' not in obj.columns or 'lon' not in obj.columns:
37-
raise AttributeError("Must have 'lat' and 'lon'.")
36+
# verify there is a column latitude and a column longitude
37+
if 'latitude' not in obj.columns or 'longitude' not in obj.columns:
38+
raise AttributeError("Must have 'latitude' and 'longitude'.")
3839
3940
@property
4041
def center(self):

doc/source/styled.xlsx

5.55 KB
Binary file not shown.

doc/source/user_guide/missing_data.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ examined :ref:`in the API <api.dataframe.missing>`.
335335
Interpolation
336336
~~~~~~~~~~~~~
337337

338-
.. versionadded:: 0.21.0
338+
.. versionadded:: 0.23.0
339339

340340
The ``limit_area`` keyword argument was added.
341341

doc/source/user_guide/timeseries.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,16 @@ We are stopping on the included end-point as it is part of the index:
633633
dft2 = dft2.swaplevel(0, 1).sort_index()
634634
dft2.loc[idx[:, '2013-01-05'], :]
635635
636+
.. versionadded:: 0.25.0
637+
638+
Slicing with string indexing also honors UTC offset.
639+
640+
.. ipython:: python
641+
642+
df = pd.DataFrame([0], index=pd.DatetimeIndex(['2019-01-01'], tz='US/Pacific'))
643+
df
644+
df['2019-01-01 12:00:00+04:00':'2019-01-01 13:00:00+04:00']
645+
636646
.. _timeseries.slice_vs_exact_match:
637647

638648
Slice vs. Exact Match

doc/source/whatsnew/v0.24.2.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Fixed Regressions
2626

2727
- Fixed regression in :meth:`DataFrame.duplicated()`, where empty dataframe was not returning a boolean dtyped Series. (:issue:`25184`)
2828
- Fixed regression in :meth:`Series.min` and :meth:`Series.max` where ``numeric_only=True`` was ignored when the ``Series`` contained ```Categorical`` data (:issue:`25299`)
29+
- Fixed regression in subtraction between :class:`Series` objects with ``datetime64[ns]`` dtype incorrectly raising ``OverflowError`` when the `Series` on the right contains null values (:issue:`25317`)
30+
- Fixed regression in :class:`TimedeltaIndex` where `np.sum(index)` incorrectly returned a zero-dimensional object instead of a scalar (:issue:`25282`)
2931
- Fixed regression in ``IntervalDtype`` construction where passing an incorrect string with 'Interval' as a prefix could result in a ``RecursionError``. (:issue:`25338`)
3032

3133
.. _whatsnew_0242.enhancements:
@@ -94,7 +96,7 @@ Bug Fixes
9496
**Other**
9597

9698
- Bug in :meth:`Series.is_unique` where single occurrences of ``NaN`` were not considered unique (:issue:`25180`)
97-
-
99+
- Bug in :func:`merge` when merging an empty ``DataFrame`` with an ``Int64`` column or a non-empty ``DataFrame`` with an ``Int64`` column that is all ``NaN`` (:issue:`25183`)
98100
-
99101

100102
.. _whatsnew_0.242.contributors:

doc/source/whatsnew/v0.25.0.rst

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,49 @@ including other versions of pandas.
1919
Other Enhancements
2020
^^^^^^^^^^^^^^^^^^
2121

22+
- Indexing of ``DataFrame`` and ``Series`` now accepts zerodim ``np.ndarray`` (:issue:`24919`)
2223
- :meth:`Timestamp.replace` now supports the ``fold`` argument to disambiguate DST transition times (:issue:`25017`)
2324
- :meth:`DataFrame.at_time` and :meth:`Series.at_time` now support :meth:`datetime.time` objects with timezones (:issue:`24043`)
25+
- :meth:`DataFrame.set_index` now works for instances of ``abc.Iterator``, provided their output is of the same length as the calling frame (:issue:`22484`, :issue:`24984`)
26+
- :meth:`DatetimeIndex.union` now supports the ``sort`` argument. The behaviour of the sort parameter matches that of :meth:`Index.union` (:issue:`24994`)
2427
-
2528

2629
.. _whatsnew_0250.api_breaking:
2730

2831
Backwards incompatible API changes
2932
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3033

31-
- :meth:`Timestamp.strptime` will now rise a NotImplementedError (:issue:`21257`)
34+
.. _whatsnew_0250.api_breaking.utc_offset_indexing:
35+
36+
Indexing with date strings with UTC offsets
37+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
39+
Indexing a :class:`DataFrame` or :class:`Series` with a :class:`DatetimeIndex` with a
40+
date string with a UTC offset would previously ignore the UTC offset. Now, the UTC offset
41+
is respected in indexing. (:issue:`24076`, :issue:`16785`)
42+
43+
*Previous Behavior*:
44+
45+
.. code-block:: ipython
46+
47+
In [1]: df = pd.DataFrame([0], index=pd.DatetimeIndex(['2019-01-01'], tz='US/Pacific'))
48+
49+
In [2]: df
50+
Out[2]:
51+
0
52+
2019-01-01 00:00:00-08:00 0
53+
54+
In [3]: df['2019-01-01 00:00:00+04:00':'2019-01-01 01:00:00+04:00']
55+
Out[3]:
56+
0
57+
2019-01-01 00:00:00-08:00 0
58+
59+
*New Behavior*:
60+
61+
.. ipython:: ipython
62+
63+
df = pd.DataFrame([0], index=pd.DatetimeIndex(['2019-01-01'], tz='US/Pacific'))
64+
df['2019-01-01 12:00:00+04:00':'2019-01-01 13:00:00+04:00']
3265

3366
.. _whatsnew_0250.api.other:
3467

@@ -37,7 +70,7 @@ Other API Changes
3770

3871
- :class:`DatetimeTZDtype` will now standardize pytz timezones to a common timezone instance (:issue:`24713`)
3972
- ``Timestamp`` and ``Timedelta`` scalars now implement the :meth:`to_numpy` method as aliases to :meth:`Timestamp.to_datetime64` and :meth:`Timedelta.to_timedelta64`, respectively. (:issue:`24653`)
40-
-
73+
- :meth:`Timestamp.strptime` will now rise a ``NotImplementedError`` (:issue:`25016`)
4174
-
4275

4376
.. _whatsnew_0250.deprecations:
@@ -63,7 +96,8 @@ Performance Improvements
6396

6497
- Significant speedup in `SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`)
6598
- `DataFrame.to_stata()` is now faster when outputting data with any string or non-native endian columns (:issue:`25045`)
66-
-
99+
- Improved performance of :meth:`Series.searchsorted`. The speedup is especially large when the dtype is
100+
int8/int16/int32 and the searched key is within the integer bounds for the dtype (:issue:`22034`)
67101

68102

69103
.. _whatsnew_0250.bug_fixes:
@@ -159,6 +193,7 @@ I/O
159193
^^^
160194

161195
- Fixed bug in missing text when using :meth:`to_clipboard` if copying utf-16 characters in Python 3 on Windows (:issue:`25040`)
196+
- Bug in :func:`read_json` for ``orient='table'`` when it tries to infer dtypes by default, which is not applicable as dtypes are already defined in the JSON schema (:issue:`21345`)
162197
-
163198
-
164199
-

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
- isort
2121
- moto
2222
- pytest>=4.0
23+
- pytest-mock
2324
- sphinx
2425
- numpydoc
2526

pandas/_libs/interval.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ cdef class Interval(IntervalMixin):
150150
Left bound for the interval.
151151
right : orderable scalar
152152
Right bound for the interval.
153-
closed : {'left', 'right', 'both', 'neither'}, default 'right'
154-
Whether the interval is closed on the left-side, right-side, both or
155-
neither.
156153
closed : {'right', 'left', 'both', 'neither'}, default 'right'
157154
Whether the interval is closed on the left-side, right-side, both or
158155
neither. See the Notes for more detailed explanation.

pandas/_libs/lib.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ _TYPE_MAP = {
939939
'float32': 'floating',
940940
'float64': 'floating',
941941
'f': 'floating',
942+
'complex64': 'complex',
942943
'complex128': 'complex',
943944
'c': 'complex',
944945
'string': 'string' if PY2 else 'bytes',
@@ -1305,6 +1306,9 @@ def infer_dtype(value: object, skipna: object=None) -> str:
13051306
elif is_decimal(val):
13061307
return 'decimal'
13071308

1309+
elif is_complex(val):
1310+
return 'complex'
1311+
13081312
elif util.is_float_object(val):
13091313
if is_float_array(values):
13101314
return 'floating'

pandas/compat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def lfilter(*args, **kwargs):
137137
reload = reload
138138
Hashable = collections.abc.Hashable
139139
Iterable = collections.abc.Iterable
140+
Iterator = collections.abc.Iterator
140141
Mapping = collections.abc.Mapping
141142
MutableMapping = collections.abc.MutableMapping
142143
Sequence = collections.abc.Sequence
@@ -199,6 +200,7 @@ def get_range_parameters(data):
199200

200201
Hashable = collections.Hashable
201202
Iterable = collections.Iterable
203+
Iterator = collections.Iterator
202204
Mapping = collections.Mapping
203205
MutableMapping = collections.MutableMapping
204206
Sequence = collections.Sequence

0 commit comments

Comments
 (0)
0