Skip to content

Commit 44740c0

Browse files
committed
resolve conflicts, remove dict c_REMOVED_ABBREVS, add msg if raise KeyError in get_reso_from_freqstr
2 parents 4085d5c + 236d89b commit 44740c0

Some content is hidden

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

70 files changed

+1262
-1034
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
skip: [pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.4.7
22+
rev: v0.5.0
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]
@@ -73,7 +73,7 @@ repos:
7373
hooks:
7474
- id: isort
7575
- repo: https://github.com/asottile/pyupgrade
76-
rev: v3.15.2
76+
rev: v3.16.0
7777
hooks:
7878
- id: pyupgrade
7979
args: [--py310-plus]
@@ -93,7 +93,7 @@ repos:
9393
- id: sphinx-lint
9494
args: ["--enable", "all", "--disable", "line-too-long"]
9595
- repo: https://github.com/pre-commit/mirrors-clang-format
96-
rev: v18.1.5
96+
rev: v18.1.8
9797
hooks:
9898
- id: clang-format
9999
files: ^pandas/_libs/src|^pandas/_libs/include

ci/code_checks.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
244244
-i "pandas.Timestamp.month_name SA01" \
245245
-i "pandas.Timestamp.nanosecond GL08" \
246246
-i "pandas.Timestamp.normalize SA01" \
247-
-i "pandas.Timestamp.now SA01" \
248247
-i "pandas.Timestamp.quarter SA01" \
249248
-i "pandas.Timestamp.replace PR07,SA01" \
250249
-i "pandas.Timestamp.resolution PR02" \
251250
-i "pandas.Timestamp.second GL08" \
252251
-i "pandas.Timestamp.strptime PR01,SA01" \
253-
-i "pandas.Timestamp.time SA01" \
254252
-i "pandas.Timestamp.timestamp SA01" \
255253
-i "pandas.Timestamp.timetuple SA01" \
256254
-i "pandas.Timestamp.timetz SA01" \

doc/source/user_guide/io.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,7 @@ a JSON string with two fields, ``schema`` and ``data``.
21612161
{
21622162
"A": [1, 2, 3],
21632163
"B": ["a", "b", "c"],
2164-
"C": pd.date_range("2016-01-01", freq="d", periods=3),
2164+
"C": pd.date_range("2016-01-01", freq="D", periods=3),
21652165
},
21662166
index=pd.Index(range(3), name="idx"),
21672167
)
@@ -2270,7 +2270,7 @@ round-trippable manner.
22702270
{
22712271
"foo": [1, 2, 3, 4],
22722272
"bar": ["a", "b", "c", "d"],
2273-
"baz": pd.date_range("2018-01-01", freq="d", periods=4),
2273+
"baz": pd.date_range("2018-01-01", freq="D", periods=4),
22742274
"qux": pd.Categorical(["a", "b", "c", "c"]),
22752275
},
22762276
index=pd.Index(range(4), name="idx"),

doc/source/whatsnew/v0.18.0.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,28 @@ Tz-aware are rounded, floored and ceiled in local times
322322
323323
Timedeltas
324324

325-
.. ipython:: python
325+
.. code-block:: ipython
326+
327+
In [37]: t = pd.timedelta_range('1 days 2 hr 13 min 45 us', periods=3, freq='d')
326328
327-
t = pd.timedelta_range('1 days 2 hr 13 min 45 us', periods=3, freq='d')
328-
t
329-
t.round('10min')
329+
In [38]: t
330+
Out[38]:
331+
TimedeltaIndex(['1 days 02:13:00.000045', '2 days 02:13:00.000045',
332+
'3 days 02:13:00.000045'],
333+
dtype='timedelta64[ns]', freq='D')
334+
335+
In [39]: t.round('10min')
336+
Out[39]:
337+
TimedeltaIndex(['1 days 02:10:00', '2 days 02:10:00',
338+
'3 days 02:10:00'],
339+
dtype='timedelta64[ns]', freq=None)
330340
331341
# Timedelta scalar
332-
t[0]
333-
t[0].round('2h')
342+
In [40]: t[0]
343+
Out[40]: Timedelta('1 days 02:13:00.000045')
344+
345+
In [41]: t[0].round('2h')
346+
Out[41]: Timedelta('1 days 02:00:00')
334347
335348
336349
In addition, ``.round()``, ``.floor()`` and ``.ceil()`` will be available through the ``.dt`` accessor of ``Series``.

doc/source/whatsnew/v0.20.0.rst

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,26 @@ The new orient ``'table'`` for :meth:`DataFrame.to_json`
308308
will generate a `Table Schema`_ compatible string representation of
309309
the data.
310310

311-
.. ipython:: python
311+
.. code-block:: ipython
312312
313-
df = pd.DataFrame(
314-
{'A': [1, 2, 3],
315-
'B': ['a', 'b', 'c'],
316-
'C': pd.date_range('2016-01-01', freq='d', periods=3)},
317-
index=pd.Index(range(3), name='idx'))
318-
df
319-
df.to_json(orient='table')
313+
In [38]: df = pd.DataFrame(
314+
....: {'A': [1, 2, 3],
315+
....: 'B': ['a', 'b', 'c'],
316+
....: 'C': pd.date_range('2016-01-01', freq='d', periods=3)},
317+
....: index=pd.Index(range(3), name='idx'))
318+
In [39]: df
319+
Out[39]:
320+
A B C
321+
idx
322+
0 1 a 2016-01-01
323+
1 2 b 2016-01-02
324+
2 3 c 2016-01-03
325+
326+
[3 rows x 3 columns]
327+
328+
In [40]: df.to_json(orient='table')
329+
Out[40]:
330+
'{"schema":{"fields":[{"name":"idx","type":"integer"},{"name":"A","type":"integer"},{"name":"B","type":"string"},{"name":"C","type":"datetime"}],"primaryKey":["idx"],"pandas_version":"1.4.0"},"data":[{"idx":0,"A":1,"B":"a","C":"2016-01-01T00:00:00.000"},{"idx":1,"A":2,"B":"b","C":"2016-01-02T00:00:00.000"},{"idx":2,"A":3,"B":"c","C":"2016-01-03T00:00:00.000"}]}'
320331
321332
322333
See :ref:`IO: Table Schema for more information <io.table_schema>`.

doc/source/whatsnew/v0.22.0.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,27 @@ sum and ``1`` for product.
157157
158158
*pandas 0.22.0*
159159

160-
.. ipython:: python
160+
.. code-block:: ipython
161+
162+
In [11]: s = pd.Series([1, 1, np.nan, np.nan],
163+
....: index=pd.date_range("2017", periods=4))
161164
162-
s = pd.Series([1, 1, np.nan, np.nan], index=pd.date_range("2017", periods=4))
163-
s.resample("2d").sum()
165+
In [12]: s.resample("2d").sum()
166+
Out[12]:
167+
2017-01-01 2.0
168+
2017-01-03 0.0
169+
Freq: 2D, Length: 2, dtype: float64
164170
165171
To restore the 0.21 behavior of returning ``NaN``, use ``min_count>=1``.
166172

167-
.. ipython:: python
173+
.. code-block:: ipython
174+
175+
In [13]: s.resample("2d").sum(min_count=1)
176+
Out[13]:
177+
2017-01-01 2.0
178+
2017-01-03 NaN
179+
Freq: 2D, Length: 2, dtype: float64
168180
169-
s.resample("2d").sum(min_count=1)
170181
171182
In particular, upsampling and taking the sum or product is affected, as
172183
upsampling introduces missing values even if the original series was

doc/source/whatsnew/v0.23.0.rst

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,55 @@ JSON read/write round-trippable with ``orient='table'``
5050

5151
A ``DataFrame`` can now be written to and subsequently read back via JSON while preserving metadata through usage of the ``orient='table'`` argument (see :issue:`18912` and :issue:`9146`). Previously, none of the available ``orient`` values guaranteed the preservation of dtypes and index names, amongst other metadata.
5252

53-
.. ipython:: python
53+
.. code-block:: ipython
5454
55-
df = pd.DataFrame({'foo': [1, 2, 3, 4],
56-
'bar': ['a', 'b', 'c', 'd'],
57-
'baz': pd.date_range('2018-01-01', freq='d', periods=4),
58-
'qux': pd.Categorical(['a', 'b', 'c', 'c'])},
59-
index=pd.Index(range(4), name='idx'))
60-
df
61-
df.dtypes
62-
df.to_json('test.json', orient='table')
63-
new_df = pd.read_json('test.json', orient='table')
64-
new_df
65-
new_df.dtypes
55+
In [1]: df = pd.DataFrame({'foo': [1, 2, 3, 4],
56+
...: 'bar': ['a', 'b', 'c', 'd'],
57+
...: 'baz': pd.date_range('2018-01-01', freq='d', periods=4),
58+
...: 'qux': pd.Categorical(['a', 'b', 'c', 'c'])},
59+
...: index=pd.Index(range(4), name='idx'))
60+
61+
In [2]: df
62+
Out[2]:
63+
foo bar baz qux
64+
idx
65+
0 1 a 2018-01-01 a
66+
1 2 b 2018-01-02 b
67+
2 3 c 2018-01-03 c
68+
3 4 d 2018-01-04 c
69+
70+
[4 rows x 4 columns]
71+
72+
In [3]: df.dtypes
73+
Out[3]:
74+
foo int64
75+
bar object
76+
baz datetime64[ns]
77+
qux category
78+
Length: 4, dtype: object
79+
80+
In [4]: df.to_json('test.json', orient='table')
81+
82+
In [5]: new_df = pd.read_json('test.json', orient='table')
83+
84+
In [6]: new_df
85+
Out[6]:
86+
foo bar baz qux
87+
idx
88+
0 1 a 2018-01-01 a
89+
1 2 b 2018-01-02 b
90+
2 3 c 2018-01-03 c
91+
3 4 d 2018-01-04 c
92+
93+
[4 rows x 4 columns]
94+
95+
In [7]: new_df.dtypes
96+
Out[7]:
97+
foo int64
98+
bar object
99+
baz datetime64[ns]
100+
qux category
101+
Length: 4, dtype: object
66102
67103
Please note that the string ``index`` is not supported with the round trip format, as it is used by default in ``write_json`` to indicate a missing index name.
68104

doc/source/whatsnew/v3.0.0.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ Other Deprecations
279279
- Deprecated allowing non-keyword arguments in :meth:`Series.to_markdown` except ``buf``. (:issue:`57280`)
280280
- Deprecated allowing non-keyword arguments in :meth:`Series.to_string` except ``buf``. (:issue:`57280`)
281281
- Deprecated behavior of :meth:`Series.dt.to_pytimedelta`, in a future version this will return a :class:`Series` containing python ``datetime.timedelta`` objects instead of an ``ndarray`` of timedelta; this matches the behavior of other :meth:`Series.dt` properties. (:issue:`57463`)
282+
- Deprecated lowercase strings ``d``, ``b`` and ``c`` denoting frequencies in :class:`Day`, :class:`BusinessDay` and :class:`CustomBusinessDay` in favour of ``D``, ``B`` and ``C`` (:issue:`58998`)
283+
- Deprecated lowercase strings ``w``, ``w-mon``, ``w-tue``, etc. denoting frequencies in :class:`Week` in favour of ``W``, ``W-MON``, ``W-TUE``, etc. (:issue:`58998`)
282284
- Deprecated parameter ``method`` in :meth:`DataFrame.reindex_like` / :meth:`Series.reindex_like` (:issue:`58667`)
283285
- Deprecated strings ``w``, ``d``, ``MIN``, ``MS``, ``US`` and ``NS`` denoting units in :class:`Timedelta` in favour of ``W``, ``D``, ``min``, ``ms``, ``us`` and ``ns`` (:issue:`59051`)
284286
- Deprecated using ``epoch`` date format in :meth:`DataFrame.to_json` and :meth:`Series.to_json`, use ``iso`` instead. (:issue:`57063`)
@@ -565,8 +567,8 @@ I/O
565567
- Bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)
566568
- Bug in :meth:`read_csv` raising ``TypeError`` when ``nrows`` and ``iterator`` are specified without specifying a ``chunksize``. (:issue:`59079`)
567569
- Bug in :meth:`read_excel` raising ``ValueError`` when passing array of boolean values when ``dtype="boolean"``. (:issue:`58159`)
570+
- Bug in :meth:`read_json` not validating the ``typ`` argument to not be exactly ``"frame"`` or ``"series"`` (:issue:`59124`)
568571
- Bug in :meth:`read_stata` raising ``KeyError`` when input file is stored in big-endian format and contains strL data. (:issue:`58638`)
569-
-
570572

571573
Period
572574
^^^^^^
@@ -598,6 +600,7 @@ Reshaping
598600
^^^^^^^^^
599601
- Bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
600602
- Bug in :meth:`DataFrame.unstack` producing incorrect results when ``sort=False`` (:issue:`54987`, :issue:`55516`)
603+
- Bug in :meth:`DataFrame.unstack` producing incorrect results when manipulating empty :class:`DataFrame` with an :class:`ExtentionDtype` (:issue:`59123`)
601604

602605
Sparse
603606
^^^^^^
@@ -617,6 +620,7 @@ Other
617620
^^^^^
618621
- Bug in :class:`DataFrame` when passing a ``dict`` with a NA scalar and ``columns`` that would always return ``np.nan`` (:issue:`57205`)
619622
- Bug in :func:`eval` on :class:`ExtensionArray` on including division ``/`` failed with a ``TypeError``. (:issue:`58748`)
623+
- Bug in :func:`eval` on :class:`complex` including division ``/`` discards imaginary part. (:issue:`21374`)
620624
- Bug in :func:`eval` where the names of the :class:`Series` were not preserved when using ``engine="numexpr"``. (:issue:`10239`)
621625
- Bug in :func:`unique` on :class:`Index` not always returning :class:`Index` (:issue:`57043`)
622626
- Bug in :meth:`DataFrame.apply` where passing ``engine="numba"`` ignored ``args`` passed to the applied function (:issue:`58712`)

pandas/_libs/src/datetime/pd_datetime.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ static int pandas_datetime_exec(PyObject *Py_UNUSED(module)) {
245245
}
246246

247247
static PyModuleDef_Slot pandas_datetime_slots[] = {
248-
{Py_mod_exec, pandas_datetime_exec}, {0, NULL}};
248+
{Py_mod_exec, pandas_datetime_exec},
249+
#if PY_VERSION_HEX >= 0x030D0000
250+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
251+
#endif
252+
{0, NULL},
253+
};
249254

250255
static struct PyModuleDef pandas_datetimemodule = {
251256
PyModuleDef_HEAD_INIT,

pandas/_libs/src/parser/pd_parser.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ static int pandas_parser_exec(PyObject *Py_UNUSED(module)) {
161161
}
162162

163163
static PyModuleDef_Slot pandas_parser_slots[] = {
164-
{Py_mod_exec, pandas_parser_exec}, {0, NULL}};
164+
{Py_mod_exec, pandas_parser_exec},
165+
#if PY_VERSION_HEX >= 0x030D0000
166+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
167+
#endif
168+
{0, NULL},
169+
};
165170

166171
static struct PyModuleDef pandas_parsermodule = {
167172
PyModuleDef_HEAD_INIT,

0 commit comments

Comments
 (0)