Skip to content

Commit 5f6ab41

Browse files
committed
Merge branch 'main' of github.com:pandas-dev/pandas into issue-37210-to-sql-truncate
2 parents 341843c + 5e50d3f commit 5f6ab41

34 files changed

+280
-159
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ BSD 3-Clause License
33
Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
44
All rights reserved.
55

6-
Copyright (c) 2011-2024, Open source contributors.
6+
Copyright (c) 2011-2025, Open source contributors.
77

88
Redistribution and use in source and binary forms, with or without
99
modification, are permitted provided that the following conditions are met:

ci/code_checks.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8181
-i "pandas.Timestamp.resolution PR02" \
8282
-i "pandas.Timestamp.tzinfo GL08" \
8383
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \
84-
-i "pandas.arrays.NumpyExtensionArray SA01" \
8584
-i "pandas.arrays.TimedeltaArray PR07,SA01" \
8685
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \
8786
-i "pandas.core.groupby.SeriesGroupBy.plot PR02" \
88-
-i "pandas.core.resample.Resampler.max PR01,RT03,SA01" \
89-
-i "pandas.core.resample.Resampler.mean SA01" \
90-
-i "pandas.core.resample.Resampler.min PR01,RT03,SA01" \
91-
-i "pandas.core.resample.Resampler.prod SA01" \
9287
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \
93-
-i "pandas.core.resample.Resampler.std SA01" \
9488
-i "pandas.core.resample.Resampler.transform PR01,RT03,SA01" \
95-
-i "pandas.core.resample.Resampler.var SA01" \
9689
-i "pandas.errors.ValueLabelTypeMismatch SA01" \
9790
-i "pandas.plotting.andrews_curves RT03,SA01" \
9891
-i "pandas.tseries.offsets.BDay PR02,SA01" \
507 KB
Binary file not shown.
119 KB
Binary file not shown.

doc/cheatsheet/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ and pick "PDF" as the format.
66

77
This cheat sheet, originally written by Irv Lustig, [Princeton Consultants](https://www.princetonoptimization.com/), was inspired by the [RStudio Data Wrangling Cheatsheet](https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf).
88

9-
| Topic | PDF | PPT |
10-
|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
11-
| Pandas_Cheat_Sheet | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet.pdf" target="_parent"><img src="https://img.shields.io/badge/Open in PDF-%23FF0000.svg?style=flat-square&logo=adobe&logoColor=white"/></a> | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet.pptx" target="_parent"><img src="https://img.shields.io/badge/Open in PPT-B7472A?style=flat-square&logo=microsoft-powerpoint&logoColor=white"/></a> |
12-
| Pandas_Cheat_Sheet_JA | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet_JA.pdf" target="_parent"><img src="https://img.shields.io/badge/Open in PDF-%23FF0000.svg?style=flat-square&logo=adobe&logoColor=white"/></a> | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet_JA.pptx" target="_parent"><img src="https://img.shields.io/badge/Open in PPT-B7472A?style=flat-square&logo=microsoft-powerpoint&logoColor=white"/></a> |
9+
| Topic | Language | PDF | PPT |
10+
|------------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
11+
| Pandas_Cheat_Sheet | English | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet.pdf" target="_parent"><img src="https://img.shields.io/badge/Open in PDF-%23FF0000.svg?style=flat-square&logo=adobe&logoColor=white"/></a> | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet.pptx" target="_parent"><img src="https://img.shields.io/badge/Open in PPT-B7472A?style=flat-square&logo=microsoft-powerpoint&logoColor=white"/></a> |
12+
| Pandas_Cheat_Sheet_JA | Japanese | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet_JA.pdf" target="_parent"><img src="https://img.shields.io/badge/Open in PDF-%23FF0000.svg?style=flat-square&logo=adobe&logoColor=white"/></a> | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet_JA.pptx" target="_parent"><img src="https://img.shields.io/badge/Open in PPT-B7472A?style=flat-square&logo=microsoft-powerpoint&logoColor=white"/></a> |
13+
| Pandas_Cheat_Sheet_FA | Persian | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet_FA.pdf" target="_parent"><img src="https://img.shields.io/badge/Open in PDF-%23FF0000.svg?style=flat-square&logo=adobe&logoColor=white"/></a> | <a href="https://github.com/pandas-dev/pandas/blob/main/doc/cheatsheet/Pandas_Cheat_Sheet_FA.pptx" target="_parent"><img src="https://img.shields.io/badge/Open in PPT-B7472A?style=flat-square&logo=microsoft-powerpoint&logoColor=white"/></a> |
14+
1315

1416

1517
**Alternative**

doc/source/user_guide/indexing.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,10 @@ and :ref:`Advanced Indexing <advanced>` you may select along more than one axis
858858
859859
.. warning::
860860

861-
``iloc`` supports two kinds of boolean indexing. If the indexer is a boolean ``Series``,
862-
an error will be raised. For instance, in the following example, ``df.iloc[s.values, 1]`` is ok.
863-
The boolean indexer is an array. But ``df.iloc[s, 1]`` would raise ``ValueError``.
861+
While ``loc`` supports two kinds of boolean indexing, ``iloc`` only supports indexing with a
862+
boolean array. If the indexer is a boolean ``Series``, an error will be raised. For instance,
863+
in the following example, ``df.iloc[s.values, 1]`` is ok. The boolean indexer is an array.
864+
But ``df.iloc[s, 1]`` would raise ``ValueError``.
864865

865866
.. ipython:: python
866867

doc/source/user_guide/visualization.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,11 +1210,6 @@ You may set the ``xlabel`` and ``ylabel`` arguments to give the plot custom labe
12101210
for x and y axis. By default, pandas will pick up index name as xlabel, while leaving
12111211
it empty for ylabel.
12121212

1213-
.. ipython:: python
1214-
:suppress:
1215-
1216-
plt.figure();
1217-
12181213
.. ipython:: python
12191214
12201215
df.plot();

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Other enhancements
6161
- :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`)
6262
- :meth:`str.get_dummies` now accepts a ``dtype`` parameter to specify the dtype of the resulting DataFrame (:issue:`47872`)
6363
- Add ``"delete_rows"`` option to ``if_exists`` argument in :meth:`DataFrame.to_sql` deleting all records of the table before inserting data (:issue:`37210`).
64+
- Implemented :meth:`Series.str.isascii` and :meth:`Series.str.isascii` (:issue:`59091`)
6465
- Multiplying two :class:`DateOffset` objects will now raise a ``TypeError`` instead of a ``RecursionError`` (:issue:`59442`)
6566
- Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`)
6667
- Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`)

pandas/_libs/index.pyx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -561,23 +561,15 @@ cdef class StringObjectEngine(ObjectEngine):
561561

562562
cdef:
563563
object na_value
564-
bint uses_na
565564

566565
def __init__(self, ndarray values, na_value):
567566
super().__init__(values)
568567
self.na_value = na_value
569-
self.uses_na = na_value is C_NA
570-
571-
cdef bint _checknull(self, object val):
572-
if self.uses_na:
573-
return val is C_NA
574-
else:
575-
return util.is_nan(val)
576568

577569
cdef _check_type(self, object val):
578570
if isinstance(val, str):
579571
return val
580-
elif self._checknull(val):
572+
elif checknull(val):
581573
return self.na_value
582574
else:
583575
raise KeyError(val)

pandas/_libs/tslibs/nattype.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ class NaTType(_NaT):
704704
difference between the current timezone and UTC.
705705
706706
Returns
707-
--------
707+
-------
708708
timedelta
709709
The difference between UTC and the local time as a `timedelta` object.
710710

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ class Timestamp(_Timestamp):
22172217
difference between the current timezone and UTC.
22182218

22192219
Returns
2220-
--------
2220+
-------
22212221
timedelta
22222222
The difference between UTC and the local time as a `timedelta` object.
22232223

pandas/core/arrays/_arrow_string_mixins.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ def _str_isalpha(self):
253253
result = pc.utf8_is_alpha(self._pa_array)
254254
return self._convert_bool_result(result)
255255

256+
def _str_isascii(self):
257+
result = pc.string_is_ascii(self._pa_array)
258+
return self._convert_bool_result(result)
259+
256260
def _str_isdecimal(self):
257261
result = pc.utf8_is_decimal(self._pa_array)
258262
return self._convert_bool_result(result)

pandas/core/arrays/arrow/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@ def interpolate(
21602160
"""
21612161
# NB: we return type(self) even if copy=False
21622162
if not self.dtype._is_numeric:
2163-
raise ValueError("Values must be numeric.")
2163+
raise TypeError(f"Cannot interpolate with {self.dtype} dtype")
21642164

21652165
if (
21662166
not pa_version_under13p0

pandas/core/arrays/numpy_.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class NumpyExtensionArray( # type: ignore[misc]
7171
-------
7272
None
7373
74+
See Also
75+
--------
76+
array : Create an array.
77+
Series.to_numpy : Convert a Series to a NumPy array.
78+
7479
Examples
7580
--------
7681
>>> pd.arrays.NumpyExtensionArray(np.array([0, 1, 2, 3]))
@@ -287,6 +292,9 @@ def interpolate(
287292
See NDFrame.interpolate.__doc__.
288293
"""
289294
# NB: we return type(self) even if copy=False
295+
if not self.dtype._is_numeric:
296+
raise TypeError(f"Cannot interpolate with {self.dtype} dtype")
297+
290298
if not copy:
291299
out_data = self._ndarray
292300
else:

pandas/core/computation/eval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ def eval(
190190
191191
.. warning::
192192
193-
``eval`` can run arbitrary code which can make you vulnerable to code
194-
injection and untrusted data.
193+
This function can run arbitrary code which can make you vulnerable to code
194+
injection if you pass user input to this function.
195195
196196
Parameters
197197
----------

pandas/core/frame.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4476,8 +4476,10 @@ def query(self, expr: str, *, inplace: bool = False, **kwargs) -> DataFrame | No
44764476
"""
44774477
Query the columns of a DataFrame with a boolean expression.
44784478
4479-
This method can run arbitrary code which can make you vulnerable to code
4480-
injection if you pass user input to this function.
4479+
.. warning::
4480+
4481+
This method can run arbitrary code which can make you vulnerable to code
4482+
injection if you pass user input to this function.
44814483
44824484
Parameters
44834485
----------
@@ -4634,6 +4636,11 @@ def eval(self, expr: str, *, inplace: bool = False, **kwargs) -> Any | None:
46344636
"""
46354637
Evaluate a string describing operations on DataFrame columns.
46364638
4639+
.. warning::
4640+
4641+
This method can run arbitrary code which can make you vulnerable to code
4642+
injection if you pass user input to this function.
4643+
46374644
Operates on columns only, not specific rows or elements. This allows
46384645
`eval` to run arbitrary code, which can make you vulnerable to code
46394646
injection if you pass user input to this function.

pandas/core/resample.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,13 @@ def prod(
10961096
Series or DataFrame
10971097
Computed prod of values within each group.
10981098
1099+
See Also
1100+
--------
1101+
core.resample.Resampler.sum : Compute sum of groups, excluding missing values.
1102+
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
1103+
core.resample.Resampler.median : Compute median of groups, excluding missing
1104+
values.
1105+
10991106
Examples
11001107
--------
11011108
>>> ser = pd.Series(
@@ -1126,9 +1133,30 @@ def min(
11261133
"""
11271134
Compute min value of group.
11281135
1136+
Parameters
1137+
----------
1138+
numeric_only : bool, default False
1139+
Include only float, int, boolean columns.
1140+
1141+
.. versionchanged:: 2.0.0
1142+
1143+
numeric_only no longer accepts ``None``.
1144+
1145+
min_count : int, default 0
1146+
The required number of valid values to perform the operation. If fewer
1147+
than ``min_count`` non-NA values are present the result will be NA.
1148+
11291149
Returns
11301150
-------
11311151
Series or DataFrame
1152+
Compute the minimum value in the given Series or DataFrame.
1153+
1154+
See Also
1155+
--------
1156+
core.resample.Resampler.max : Compute max value of group.
1157+
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
1158+
core.resample.Resampler.median : Compute median of groups, excluding missing
1159+
values.
11321160
11331161
Examples
11341162
--------
@@ -1160,9 +1188,30 @@ def max(
11601188
"""
11611189
Compute max value of group.
11621190
1191+
Parameters
1192+
----------
1193+
numeric_only : bool, default False
1194+
Include only float, int, boolean columns.
1195+
1196+
.. versionchanged:: 2.0.0
1197+
1198+
numeric_only no longer accepts ``None``.
1199+
1200+
min_count : int, default 0
1201+
The required number of valid values to perform the operation. If fewer
1202+
than ``min_count`` non-NA values are present the result will be NA.
1203+
11631204
Returns
11641205
-------
11651206
Series or DataFrame
1207+
Computes the maximum value in the given Series or Dataframe.
1208+
1209+
See Also
1210+
--------
1211+
core.resample.Resampler.min : Compute min value of group.
1212+
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
1213+
core.resample.Resampler.median : Compute median of groups, excluding missing
1214+
values.
11661215
11671216
Examples
11681217
--------
@@ -1236,6 +1285,16 @@ def mean(
12361285
DataFrame or Series
12371286
Mean of values within each group.
12381287
1288+
See Also
1289+
--------
1290+
core.resample.Resampler.median : Compute median of groups, excluding missing
1291+
values.
1292+
core.resample.Resampler.sum : Compute sum of groups, excluding missing values.
1293+
core.resample.Resampler.std : Compute standard deviation of groups, excluding
1294+
missing values.
1295+
core.resample.Resampler.var : Compute variance of groups, excluding missing
1296+
values.
1297+
12391298
Examples
12401299
--------
12411300
@@ -1285,6 +1344,14 @@ def std(
12851344
DataFrame or Series
12861345
Standard deviation of values within each group.
12871346
1347+
See Also
1348+
--------
1349+
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
1350+
core.resample.Resampler.median : Compute median of groups, excluding missing
1351+
values.
1352+
core.resample.Resampler.var : Compute variance of groups, excluding missing
1353+
values.
1354+
12881355
Examples
12891356
--------
12901357
@@ -1336,6 +1403,14 @@ def var(
13361403
DataFrame or Series
13371404
Variance of values within each group.
13381405
1406+
See Also
1407+
--------
1408+
core.resample.Resampler.std : Compute standard deviation of groups, excluding
1409+
missing values.
1410+
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
1411+
core.resample.Resampler.median : Compute median of groups, excluding missing
1412+
values.
1413+
13391414
Examples
13401415
--------
13411416

0 commit comments

Comments
 (0)