Skip to content

Commit 9277cf5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into python-db-dtypes-pandas-issue28
2 parents 38018e6 + d1ecf63 commit 9277cf5

File tree

28 files changed

+387
-162
lines changed

28 files changed

+387
-162
lines changed

.github/workflows/code-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737
- name: Run pre-commit
3838
uses: pre-commit/action@v2.0.3
3939

40-
typing_and_docstring_validation:
41-
name: Docstring and typing validation
40+
docstring_typing_pylint:
41+
name: Docstring validation, typing, and pylint
4242
runs-on: ubuntu-latest
4343
defaults:
4444
run:

.github/workflows/package-checks.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ on:
99
branches:
1010
- main
1111
- 1.5.x
12+
types: [ labeled, opened, synchronize, reopened ]
1213

1314
permissions:
1415
contents: read
1516

1617
jobs:
1718
pip:
19+
if: ${{ github.event.label.name == 'Build' || contains(github.event.pull_request.labels.*.name, 'Build') || github.event_name == 'push'}}
1820
runs-on: ubuntu-latest
1921
strategy:
2022
matrix:
@@ -38,13 +40,6 @@ jobs:
3840
with:
3941
python-version: '3.8'
4042

41-
# Hacky patch to disable building cython extensions.
42-
# This job should only check that the extras successfully install.
43-
- name: Disable building ext_modules
44-
run: |
45-
sed -i '/ext_modules=/d' setup.py
46-
shell: bash -el {0}
47-
4843
- name: Install required dependencies
4944
run: |
5045
python -m pip install --upgrade pip setuptools wheel python-dateutil pytz numpy cython

.pre-commit-config.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ repos:
6464
hooks:
6565
- id: pylint
6666
stages: [manual]
67+
- repo: https://github.com/pycqa/pylint
68+
rev: v2.15.5
69+
hooks:
70+
- id: pylint
71+
alias: redefined-outer-name
72+
name: Redefining name from outer scope
73+
files: ^pandas/
74+
exclude: |
75+
(?x)
76+
^pandas/tests # keep excluded
77+
|/_testing/ # keep excluded
78+
|^pandas/util/_test_decorators\.py # keep excluded
79+
|^pandas/_version\.py # keep excluded
80+
|^pandas/conftest\.py # keep excluded
81+
|^pandas/core/tools/datetimes\.py
82+
|^pandas/io/formats/format\.py
83+
|^pandas/core/generic\.py
84+
args: [--disable=all, --enable=redefined-outer-name]
85+
stages: [manual]
6786
- repo: https://github.com/PyCQA/isort
6887
rev: 5.10.1
6988
hooks:
@@ -201,7 +220,7 @@ repos:
201220
entry: python scripts/sync_flake8_versions.py
202221
files: ^(\.pre-commit-config\.yaml|environment\.yml)$
203222
pass_filenames: false
204-
additional_dependencies: [pyyaml]
223+
additional_dependencies: [pyyaml, toml]
205224
- id: title-capitalization
206225
name: Validate correct capitalization among titles in documentation
207226
entry: python scripts/validate_rst_title_capitalization.py

doc/source/whatsnew/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Version 1.5
2424
.. toctree::
2525
:maxdepth: 2
2626

27+
v1.5.3
2728
v1.5.2
2829
v1.5.1
2930
v1.5.0

doc/source/whatsnew/v1.5.3.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _whatsnew_153:
2+
3+
What's new in 1.5.3 (December ??, 2022)
4+
---------------------------------------
5+
6+
These are the changes in pandas 1.5.3. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
{{ header }}
10+
11+
.. ---------------------------------------------------------------------------
12+
.. _whatsnew_153.regressions:
13+
14+
Fixed regressions
15+
~~~~~~~~~~~~~~~~~
16+
- Fixed performance regression in :meth:`Series.isin` when ``values`` is empty (:issue:`49839`)
17+
-
18+
19+
.. ---------------------------------------------------------------------------
20+
.. _whatsnew_153.bug_fixes:
21+
22+
Bug fixes
23+
~~~~~~~~~
24+
-
25+
-
26+
27+
.. ---------------------------------------------------------------------------
28+
.. _whatsnew_153.other:
29+
30+
Other
31+
~~~~~
32+
-
33+
-
34+
35+
.. ---------------------------------------------------------------------------
36+
.. _whatsnew_153.contributors:
37+
38+
Contributors
39+
~~~~~~~~~~~~
40+
41+
.. contributors:: v1.5.2..v1.5.3|HEAD

doc/source/whatsnew/v2.0.0.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sql-other, html, xml, plot, output_formatting, clipboard, compression, test]`` (
3333
Configuration option, ``io.nullable_backend``, to return pyarrow-backed dtypes from IO functions
3434
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3535

36-
A new global configuration, ``io.nullable_backend`` can now be used in conjunction with the parameter ``use_nullable_dtypes=True`` in :func:`read_parquet` and :func:`read_csv` (with ``engine="pyarrow"``)
36+
A new global configuration, ``io.nullable_backend`` can now be used in conjunction with the parameter ``use_nullable_dtypes=True`` in :func:`read_parquet`, :func:`read_orc` and :func:`read_csv` (with ``engine="pyarrow"``)
3737
to return pyarrow-backed dtypes when set to ``"pyarrow"`` (:issue:`48957`).
3838

3939
.. ipython:: python
@@ -45,7 +45,7 @@ to return pyarrow-backed dtypes when set to ``"pyarrow"`` (:issue:`48957`).
4545
""")
4646
with pd.option_context("io.nullable_backend", "pyarrow"):
4747
df = pd.read_csv(data, use_nullable_dtypes=True, engine="pyarrow")
48-
df
48+
df.dtypes
4949
5050
.. _whatsnew_200.enhancements.other:
5151

@@ -349,6 +349,8 @@ Other API changes
349349
- Changed behavior of :class:`Index` constructor with sequence containing at least one ``NaT`` and everything else either ``None`` or ``NaN`` to infer ``datetime64[ns]`` dtype instead of ``object``, matching :class:`Series` behavior (:issue:`49340`)
350350
- :func:`read_stata` with parameter ``index_col`` set to ``None`` (the default) will now set the index on the returned :class:`DataFrame` to a :class:`RangeIndex` instead of a :class:`Int64Index` (:issue:`49745`)
351351
- Changed behavior of :class:`Index` constructor with an object-dtype ``numpy.ndarray`` containing all-``bool`` values or all-complex values, this will now retain object dtype, consistent with the :class:`Series` behavior (:issue:`49594`)
352+
- Changed behavior of :meth:`DataFrame.shift` with ``axis=1``, an integer ``fill_value``, and homogeneous datetime-like dtype, this now fills new columns with integer dtypes instead of casting to datetimelike (:issue:`49842`)
353+
- :meth:`DataFrame.values`, :meth:`DataFrame.to_numpy`, :meth:`DataFrame.xs`, :meth:`DataFrame.reindex`, :meth:`DataFrame.fillna`, and :meth:`DataFrame.replace` no longer silently consolidate the underlying arrays; do ``df = df.copy()`` to ensure consolidation (:issue:`49356`)
352354
-
353355

354356
.. ---------------------------------------------------------------------------
@@ -608,6 +610,7 @@ Performance improvements
608610
- Performance improvement in :class:`DataFrameGroupBy` and :class:`SeriesGroupBy` when ``by`` is a categorical type and ``observed=False`` (:issue:`49596`)
609611
- Performance improvement in :func:`read_stata` with parameter ``index_col`` set to ``None`` (the default). Now the index will be a :class:`RangeIndex` instead of :class:`Int64Index` (:issue:`49745`)
610612
- Performance improvement in :func:`merge` when not merging on the index - the new index will now be :class:`RangeIndex` instead of :class:`Int64Index` (:issue:`49478`)
613+
- Performance improvement in :meth:`DataFrame.to_dict` and :meth:`Series.to_dict` when using any non-object dtypes (:issue:`46470`)
611614

612615
.. ---------------------------------------------------------------------------
613616
.. _whatsnew_200.bug_fixes:

pandas/_libs/lib.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,8 @@ def infer_dtype(value: object, skipna: bool = True) -> str:
14381438
else:
14391439
if not isinstance(value, list):
14401440
value = list(value)
1441+
if not value:
1442+
return "empty"
14411443

14421444
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
14431445
values = construct_1d_object_array_from_listlike(value)

pandas/_libs/src/headers/portable.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
#ifndef _PANDAS_PORTABLE_H_
22
#define _PANDAS_PORTABLE_H_
33

4-
// To get `strdup` from strings.h
5-
#ifndef _XOPEN_SOURCE
6-
#define _XOPEN_SOURCE 600
7-
#endif
8-
94
#include <string.h>
105

116
#if defined(_MSC_VER)
127
#define strcasecmp( s1, s2 ) _stricmp( s1, s2 )
13-
#define strdup _strdup
148
#endif
159

1610
// GH-23516 - works around locale perf issues

pandas/_libs/src/ujson/lib/ultrajsondec.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,15 +1174,21 @@ JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer,
11741174
ds.dec = dec;
11751175

11761176
locale = setlocale(LC_NUMERIC, NULL);
1177+
if (!locale) {
1178+
return SetError(&ds, -1, "setlocale call failed");
1179+
}
1180+
11771181
if (strcmp(locale, "C")) {
1178-
locale = strdup(locale);
1179-
if (!locale) {
1180-
return SetError(&ds, -1, "Could not reserve memory block");
1182+
size_t len = strlen(locale) + 1;
1183+
char *saved_locale = malloc(len);
1184+
if (saved_locale == NULL) {
1185+
return SetError(&ds, -1, "Could not reserve memory block");
11811186
}
1187+
memcpy(saved_locale, locale, len);
11821188
setlocale(LC_NUMERIC, "C");
11831189
ret = decode_any(&ds);
1184-
setlocale(LC_NUMERIC, locale);
1185-
free(locale);
1190+
setlocale(LC_NUMERIC, saved_locale);
1191+
free(saved_locale);
11861192
} else {
11871193
ret = decode_any(&ds);
11881194
}

pandas/_libs/src/ujson/lib/ultrajsonenc.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,16 +1176,23 @@ char *JSON_EncodeObject(JSOBJ obj, JSONObjectEncoder *enc, char *_buffer,
11761176
enc->offset = enc->start;
11771177

11781178
locale = setlocale(LC_NUMERIC, NULL);
1179+
if (!locale) {
1180+
SetError(NULL, enc, "setlocale call failed");
1181+
return NULL;
1182+
}
1183+
11791184
if (strcmp(locale, "C")) {
1180-
locale = strdup(locale);
1181-
if (!locale) {
1182-
SetError(NULL, enc, "Could not reserve memory block");
1183-
return NULL;
1185+
size_t len = strlen(locale) + 1;
1186+
char *saved_locale = malloc(len);
1187+
if (saved_locale == NULL) {
1188+
SetError(NULL, enc, "Could not reserve memory block");
1189+
return NULL;
11841190
}
1191+
memcpy(saved_locale, locale, len);
11851192
setlocale(LC_NUMERIC, "C");
11861193
encode(obj, enc, NULL, 0);
1187-
setlocale(LC_NUMERIC, locale);
1188-
free(locale);
1194+
setlocale(LC_NUMERIC, saved_locale);
1195+
free(saved_locale);
11891196
} else {
11901197
encode(obj, enc, NULL, 0);
11911198
}

0 commit comments

Comments
 (0)