Skip to content

Commit 4a338ae

Browse files
Merge remote-tracking branch 'upstream/main' into string-dtype-tests-indexes
2 parents bf696db + d8905e4 commit 4a338ae

File tree

20 files changed

+250
-111
lines changed

20 files changed

+250
-111
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ minimum_pre_commit_version: 2.15.0
22
exclude: ^LICENSES/|\.(html|csv|svg)$
33
# reserve "manual" for relatively slow hooks which we still want to run in CI
44
default_stages: [
5-
commit,
6-
merge-commit,
7-
push,
5+
pre-commit,
6+
pre-merge-commit,
7+
pre-push,
88
prepare-commit-msg,
99
commit-msg,
1010
post-checkout,

ci/code_checks.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8585
-i "pandas.Timestamp.resolution PR02" \
8686
-i "pandas.Timestamp.tzinfo GL08" \
8787
-i "pandas.Timestamp.year GL08" \
88-
-i "pandas.api.types.is_integer PR01,SA01" \
8988
-i "pandas.api.types.is_iterator PR07,SA01" \
9089
-i "pandas.api.types.is_re_compilable PR07,SA01" \
9190
-i "pandas.api.types.pandas_dtype PR07,RT03,SA01" \
@@ -123,11 +122,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
123122
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \
124123
-i "pandas.core.resample.Resampler.sem SA01" \
125124
-i "pandas.core.resample.Resampler.std SA01" \
126-
-i "pandas.core.resample.Resampler.sum SA01" \
127125
-i "pandas.core.resample.Resampler.transform PR01,RT03,SA01" \
128126
-i "pandas.core.resample.Resampler.var SA01" \
129127
-i "pandas.errors.AttributeConflictWarning SA01" \
130-
-i "pandas.errors.CSSWarning SA01" \
131128
-i "pandas.errors.ChainedAssignmentError SA01" \
132129
-i "pandas.errors.DataError SA01" \
133130
-i "pandas.errors.DuplicateLabelError SA01" \
@@ -136,19 +133,15 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
136133
-i "pandas.errors.NullFrequencyError SA01" \
137134
-i "pandas.errors.NumExprClobberingError SA01" \
138135
-i "pandas.errors.NumbaUtilError SA01" \
139-
-i "pandas.errors.OptionError SA01" \
140136
-i "pandas.errors.OutOfBoundsTimedelta SA01" \
141137
-i "pandas.errors.PerformanceWarning SA01" \
142138
-i "pandas.errors.PossibleDataLossError SA01" \
143-
-i "pandas.errors.PossiblePrecisionLoss SA01" \
144139
-i "pandas.errors.UndefinedVariableError PR01,SA01" \
145140
-i "pandas.errors.UnsortedIndexError SA01" \
146-
-i "pandas.errors.UnsupportedFunctionCall SA01" \
147141
-i "pandas.errors.ValueLabelTypeMismatch SA01" \
148142
-i "pandas.infer_freq SA01" \
149143
-i "pandas.io.json.build_table_schema PR07,RT03,SA01" \
150144
-i "pandas.io.stata.StataWriter.write_file SA01" \
151-
-i "pandas.json_normalize RT03,SA01" \
152145
-i "pandas.plotting.andrews_curves RT03,SA01" \
153146
-i "pandas.plotting.scatter_matrix PR07,SA01" \
154147
-i "pandas.set_eng_float_format RT03,SA01" \
@@ -297,7 +290,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
297290
-i "pandas.tseries.offsets.Second.is_on_offset GL08" \
298291
-i "pandas.tseries.offsets.Second.n GL08" \
299292
-i "pandas.tseries.offsets.Second.normalize GL08" \
300-
-i "pandas.tseries.offsets.SemiMonthBegin SA01" \
301293
-i "pandas.tseries.offsets.SemiMonthBegin.day_of_month GL08" \
302294
-i "pandas.tseries.offsets.SemiMonthBegin.is_on_offset GL08" \
303295
-i "pandas.tseries.offsets.SemiMonthBegin.n GL08" \

doc/source/development/contributing_codebase.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ So, before actually writing any code, you should write your tests. Often the te
298298
taken from the original GitHub issue. However, it is always worth considering additional
299299
use cases and writing corresponding tests.
300300

301+
We use `code coverage <https://en.wikipedia.org/wiki/Code_coverage>`_ to help understand
302+
the amount of code which is covered by a test. We recommend striving to ensure code
303+
you add or change within Pandas is covered by a test. Please see our
304+
`code coverage dashboard through Codecov <https://app.codecov.io/github/pandas-dev/pandas>`_
305+
for more information.
306+
301307
Adding tests is one of the most common requests after code is pushed to pandas. Therefore,
302308
it is worth getting in the habit of writing tests ahead of time so this is never an issue.
303309

pandas/_config/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ class OptionError(AttributeError, KeyError):
105105
106106
Backwards compatible with KeyError checks.
107107
108+
See Also
109+
--------
110+
options : Access and modify global pandas settings.
111+
108112
Examples
109113
--------
110114
>>> pd.options.context

pandas/_libs/lib.pyx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,9 +1122,23 @@ def is_integer(obj: object) -> bool:
11221122
"""
11231123
Return True if given object is integer.
11241124

1125+
This method checks whether the passed object is an integer type. It
1126+
returns `True` if the object is an integer, and `False` otherwise.
1127+
1128+
Parameters
1129+
----------
1130+
obj : object
1131+
The object to check for integer type.
1132+
11251133
Returns
11261134
-------
11271135
bool
1136+
`True` if the object is of integer type, otherwise `False`.
1137+
1138+
See Also
1139+
--------
1140+
api.types.is_float : Check if an object is of float type.
1141+
api.types.is_numeric_dtype : Check if an object is of numeric type.
11281142

11291143
Examples
11301144
--------

pandas/_libs/tslibs/offsets.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,6 +3371,10 @@ cdef class SemiMonthBegin(SemiMonthOffset):
33713371
"""
33723372
Two DateOffset's per month repeating on the first day of the month & day_of_month.
33733373
3374+
This offset moves dates to the first day of the month and an additional specified
3375+
day (typically the 15th by default), useful in scenarios where bi-monthly processing
3376+
occurs on set days.
3377+
33743378
Attributes
33753379
----------
33763380
n : int, default 1
@@ -3380,6 +3384,13 @@ cdef class SemiMonthBegin(SemiMonthOffset):
33803384
day_of_month : int, {1, 3,...,27}, default 15
33813385
A specific integer for the day of the month.
33823386
3387+
See Also
3388+
--------
3389+
tseries.offsets.SemiMonthEnd : Two DateOffset's per month repeating on the last day
3390+
of the month & day_of_month.
3391+
tseries.offsets.MonthEnd : Offset to the last calendar day of the month.
3392+
tseries.offsets.MonthBegin : Offset to the first calendar day of the month.
3393+
33833394
Examples
33843395
--------
33853396
>>> ts = pd.Timestamp(2022, 1, 1)

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,10 +1864,12 @@ class Timedelta(_Timedelta):
18641864
18651865
Parameters
18661866
----------
1867-
value : Timedelta, timedelta, np.timedelta64, str, or int
1867+
value : Timedelta, timedelta, np.timedelta64, str, int or float
18681868
Input value.
18691869
unit : str, default 'ns'
1870-
Denote the unit of the input, if input is an integer.
1870+
If input is an integer, denote the unit of the input.
1871+
If input is a float, denote the unit of the integer parts.
1872+
The decimal parts with resolution lower than 1 nanosecond are ignored.
18711873
18721874
Possible values:
18731875

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10823,7 +10823,7 @@ def round(
1082310823
self, decimals: int | dict[IndexLabel, int] | Series = 0, *args, **kwargs
1082410824
) -> DataFrame:
1082510825
"""
10826-
Round a DataFrame to a variable number of decimal places.
10826+
Round numeric columns in a DataFrame to a variable number of decimal places.
1082710827
1082810828
Parameters
1082910829
----------

pandas/core/resample.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,10 @@ def sum(
10211021
"""
10221022
Compute sum of group values.
10231023
1024+
This method provides a simple way to compute the sum of values within each
1025+
resampled group, particularly useful for aggregating time-based data into
1026+
daily, monthly, or yearly sums.
1027+
10241028
Parameters
10251029
----------
10261030
numeric_only : bool, default False
@@ -1039,6 +1043,14 @@ def sum(
10391043
Series or DataFrame
10401044
Computed sum of values within each group.
10411045
1046+
See Also
1047+
--------
1048+
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
1049+
core.resample.Resampler.count : Compute count of group, excluding missing
1050+
values.
1051+
DataFrame.resample : Resample time-series data.
1052+
Series.sum : Return the sum of the values over the requested axis.
1053+
10421054
Examples
10431055
--------
10441056
>>> ser = pd.Series(

pandas/core/strings/accessor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ def _validate(data):
255255
inferred_dtype = lib.infer_dtype(values, skipna=True)
256256

257257
if inferred_dtype not in allowed_types:
258-
raise AttributeError("Can only use .str accessor with string values!")
258+
raise AttributeError(
259+
f"Can only use .str accessor with string values, not {inferred_dtype}"
260+
)
259261
return inferred_dtype
260262

261263
def __getitem__(self, key):

0 commit comments

Comments
 (0)