Skip to content

Commit 54fc094

Browse files
authored
Merge branch 'main' into outofbounds
2 parents 1460052 + 6e1a040 commit 54fc094

Some content is hidden

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

61 files changed

+355
-305
lines changed

.github/workflows/codeql.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CodeQL
2+
on:
3+
schedule:
4+
# every day at midnight
5+
- cron: "0 0 * * *"
6+
7+
concurrency:
8+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
analyze:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
actions: read
16+
contents: read
17+
security-events: write
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
language:
23+
- python
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: github/codeql-action/init@v2
28+
with:
29+
languages: ${{ matrix.language }}
30+
- uses: github/codeql-action/autobuild@v2
31+
- uses: github/codeql-action/analyze@v2

ci/code_checks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ fi
7878
### DOCSTRINGS ###
7979
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8080

81-
MSG='Validate docstrings (EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05)' ; echo $MSG
82-
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05
81+
MSG='Validate docstrings (EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
82+
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
8383
RET=$(($RET + $?)) ; echo $MSG "DONE"
8484

8585
fi

doc/source/reference/general_functions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ Importing from other DataFrame libraries
8585
.. autosummary::
8686
:toctree: api/
8787

88-
api.exchange.from_dataframe
88+
api.interchange.from_dataframe

pandas/_config/config.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ class RegisteredOption(NamedTuple):
102102

103103
class OptionError(AttributeError, KeyError):
104104
"""
105-
Exception for pandas.options, backwards compatible with KeyError
106-
checks.
105+
Exception raised for pandas.options.
106+
107+
Backwards compatible with KeyError checks.
107108
"""
108109

109110

pandas/_libs/groupby.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def group_any_all(
5050
val_test: Literal["any", "all"],
5151
skipna: bool,
5252
) -> None: ...
53-
def group_add(
53+
def group_sum(
5454
out: np.ndarray, # complexfloating_t[:, ::1]
5555
counts: np.ndarray, # int64_t[::1]
5656
values: np.ndarray, # ndarray[complexfloating_t, ndim=2]

pandas/_libs/groupby.pyx

+15-15
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def group_median_float64(
124124
ndarray[intp_t] indexer
125125
float64_t* ptr
126126

127-
assert min_count == -1, "'min_count' only used in add and prod"
127+
assert min_count == -1, "'min_count' only used in sum and prod"
128128

129129
ngroups = len(counts)
130130
N, K = (<object>values).shape
@@ -502,7 +502,7 @@ def group_any_all(
502502

503503

504504
# ----------------------------------------------------------------------
505-
# group_add, group_prod, group_var, group_mean, group_ohlc
505+
# group_sum, group_prod, group_var, group_mean, group_ohlc
506506
# ----------------------------------------------------------------------
507507

508508
ctypedef fused mean_t:
@@ -511,17 +511,17 @@ ctypedef fused mean_t:
511511
complex64_t
512512
complex128_t
513513

514-
ctypedef fused add_t:
514+
ctypedef fused sum_t:
515515
mean_t
516516
object
517517

518518

519519
@cython.wraparound(False)
520520
@cython.boundscheck(False)
521-
def group_add(
522-
add_t[:, ::1] out,
521+
def group_sum(
522+
sum_t[:, ::1] out,
523523
int64_t[::1] counts,
524-
ndarray[add_t, ndim=2] values,
524+
ndarray[sum_t, ndim=2] values,
525525
const intp_t[::1] labels,
526526
Py_ssize_t min_count=0,
527527
bint is_datetimelike=False,
@@ -531,8 +531,8 @@ def group_add(
531531
"""
532532
cdef:
533533
Py_ssize_t i, j, N, K, lab, ncounts = len(counts)
534-
add_t val, t, y
535-
add_t[:, ::1] sumx, compensation
534+
sum_t val, t, y
535+
sum_t[:, ::1] sumx, compensation
536536
int64_t[:, ::1] nobs
537537
Py_ssize_t len_values = len(values), len_labels = len(labels)
538538

@@ -546,7 +546,7 @@ def group_add(
546546

547547
N, K = (<object>values).shape
548548

549-
if add_t is object:
549+
if sum_t is object:
550550
# NB: this does not use 'compensation' like the non-object track does.
551551
for i in range(N):
552552
lab = labels[i]
@@ -588,10 +588,10 @@ def group_add(
588588

589589
# not nan
590590
# With dt64/td64 values, values have been cast to float64
591-
# instead if int64 for group_add, but the logic
591+
# instead if int64 for group_sum, but the logic
592592
# is otherwise the same as in _treat_as_na
593593
if val == val and not (
594-
add_t is float64_t
594+
sum_t is float64_t
595595
and is_datetimelike
596596
and val == <float64_t>NPY_NAT
597597
):
@@ -677,7 +677,7 @@ def group_var(
677677
int64_t[:, ::1] nobs
678678
Py_ssize_t len_values = len(values), len_labels = len(labels)
679679

680-
assert min_count == -1, "'min_count' only used in add and prod"
680+
assert min_count == -1, "'min_count' only used in sum and prod"
681681

682682
if len_values != len_labels:
683683
raise ValueError("len(index) != len(labels)")
@@ -745,7 +745,7 @@ def group_mean(
745745
Array containing unique label for each group, with its
746746
ordering matching up to the corresponding record in `values`.
747747
min_count : Py_ssize_t
748-
Only used in add and prod. Always -1.
748+
Only used in sum and prod. Always -1.
749749
is_datetimelike : bool
750750
True if `values` contains datetime-like entries.
751751
mask : ndarray[bool, ndim=2], optional
@@ -766,7 +766,7 @@ def group_mean(
766766
int64_t[:, ::1] nobs
767767
Py_ssize_t len_values = len(values), len_labels = len(labels)
768768

769-
assert min_count == -1, "'min_count' only used in add and prod"
769+
assert min_count == -1, "'min_count' only used in sum and prod"
770770

771771
if len_values != len_labels:
772772
raise ValueError("len(index) != len(labels)")
@@ -821,7 +821,7 @@ def group_ohlc(
821821
Py_ssize_t i, j, N, K, lab
822822
floating val
823823

824-
assert min_count == -1, "'min_count' only used in add and prod"
824+
assert min_count == -1, "'min_count' only used in sum and prod"
825825

826826
if len(labels) == 0:
827827
return

pandas/_libs/interval.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ cdef class Interval(IntervalMixin):
352352

353353
cdef readonly str inclusive
354354
"""
355-
Whether the interval is inclusive on the left-side, right-side, both or
356-
neither.
355+
String describing the inclusive side the intervals.
356+
357+
Either ``left``, ``right``, ``both`` or ``neither``.
357358
"""
358359

359360
def __init__(self, left, right, inclusive: str | None = None, closed: None | lib.NoDefault = lib.no_default):
@@ -384,10 +385,11 @@ cdef class Interval(IntervalMixin):
384385
@property
385386
def closed(self):
386387
"""
387-
Whether the interval is closed on the left-side, right-side, both or
388-
neither.
388+
String describing the inclusive side the intervals.
389389
390390
.. deprecated:: 1.5.0
391+
392+
Either ``left``, ``right``, ``both`` or ``neither``.
391393
"""
392394
warnings.warn(
393395
"Attribute `closed` is deprecated in favor of `inclusive`.",

pandas/_libs/lib.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,7 @@ cdef object _try_infer_map(object dtype):
13471347

13481348
def infer_dtype(value: object, skipna: bool = True) -> str:
13491349
"""
1350-
Efficiently infer the type of a passed val, or list-like
1351-
array of values. Return a string describing the type.
1350+
Return a string label of the type of a scalar or list-like of values.
13521351

13531352
Parameters
13541353
----------

pandas/_libs/tslibs/nattype.pyx

+14-16
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,15 @@ class NaTType(_NaT):
446446
"weekday",
447447
"""
448448
Return the day of the week represented by the date.
449+
449450
Monday == 0 ... Sunday == 6.
450451
""",
451452
)
452453
isoweekday = _make_nan_func(
453454
"isoweekday",
454455
"""
455456
Return the day of the week represented by the date.
457+
456458
Monday == 1 ... Sunday == 7.
457459
""",
458460
)
@@ -533,10 +535,7 @@ class NaTType(_NaT):
533535
strftime = _make_error_func(
534536
"strftime",
535537
"""
536-
Timestamp.strftime(format)
537-
538-
Return a string representing the given POSIX timestamp
539-
controlled by an explicit format string.
538+
Return a formatted string of the Timestamp.
540539
541540
Parameters
542541
----------
@@ -680,10 +679,7 @@ class NaTType(_NaT):
680679
fromordinal = _make_error_func(
681680
"fromordinal",
682681
"""
683-
Timestamp.fromordinal(ordinal, freq=None, tz=None)
684-
685-
Passed an ordinal, translate and convert to a ts.
686-
Note: by definition there cannot be any tz info on the ordinal itself.
682+
Construct a timestamp from a a proleptic Gregorian ordinal.
687683
688684
Parameters
689685
----------
@@ -694,6 +690,10 @@ class NaTType(_NaT):
694690
tz : str, pytz.timezone, dateutil.tz.tzfile or None
695691
Time zone for the Timestamp.
696692
693+
Notes
694+
-----
695+
By definition there cannot be any tz info on the ordinal itself.
696+
697697
Examples
698698
--------
699699
>>> pd.Timestamp.fromordinal(737425)
@@ -725,10 +725,7 @@ class NaTType(_NaT):
725725
now = _make_nat_func(
726726
"now",
727727
"""
728-
Timestamp.now(tz=None)
729-
730-
Return new Timestamp object representing current time local to
731-
tz.
728+
Return new Timestamp object representing current time local to tz.
732729
733730
Parameters
734731
----------
@@ -749,10 +746,9 @@ class NaTType(_NaT):
749746
today = _make_nat_func(
750747
"today",
751748
"""
752-
Timestamp.today(cls, tz=None)
749+
Return the current time in the local timezone.
753750
754-
Return the current time in the local timezone. This differs
755-
from datetime.today() in that it can be localized to a
751+
This differs from datetime.today() in that it can be localized to a
756752
passed timezone.
757753
758754
Parameters
@@ -1090,7 +1086,9 @@ timedelta}, default 'raise'
10901086
tz_localize = _make_nat_func(
10911087
"tz_localize",
10921088
"""
1093-
Convert naive Timestamp to local time zone, or remove
1089+
Localize the Timestamp to a timezone.
1090+
1091+
Convert naive Timestamp to local time zone or remove
10941092
timezone from timezone-aware Timestamp.
10951093
10961094
Parameters

pandas/_libs/tslibs/np_datetime.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ cdef inline bint cmp_scalar(int64_t lhs, int64_t rhs, int op) except -1:
156156

157157
class OutOfBoundsDatetime(ValueError):
158158
"""
159-
Raised when the datetime is outside the range that
160-
can be represented.
159+
Raised when the datetime is outside the range that can be represented.
161160
"""
162161
pass
163162

164163

165164
class OutOfBoundsTimedelta(ValueError):
166165
"""
167-
Raised when encountering a timedelta value that cannot be represented
168-
as a timedelta64[ns].
166+
Raised when encountering a timedelta value that cannot be represented.
167+
168+
Representation should be within a timedelta64[ns].
169169
"""
170170
# Timedelta analogue to OutOfBoundsDatetime
171171
pass

pandas/_libs/tslibs/offsets.pyx

+10-13
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,7 @@ cdef class BaseOffset:
585585

586586
def apply_index(self, dtindex):
587587
"""
588-
Vectorized apply of DateOffset to DatetimeIndex,
589-
raises NotImplementedError for offsets without a
590-
vectorized implementation.
588+
Vectorized apply of DateOffset to DatetimeIndex.
591589
592590
.. deprecated:: 1.1.0
593591
@@ -2448,8 +2446,7 @@ cdef class SemiMonthOffset(SingleConstructorOffset):
24482446

24492447
cdef class SemiMonthEnd(SemiMonthOffset):
24502448
"""
2451-
Two DateOffset's per month repeating on the last
2452-
day of the month and day_of_month.
2449+
Two DateOffset's per month repeating on the last day of the month & day_of_month.
24532450
24542451
Parameters
24552452
----------
@@ -2470,8 +2467,7 @@ cdef class SemiMonthEnd(SemiMonthOffset):
24702467

24712468
cdef class SemiMonthBegin(SemiMonthOffset):
24722469
"""
2473-
Two DateOffset's per month repeating on the first
2474-
day of the month and day_of_month.
2470+
Two DateOffset's per month repeating on the first day of the month & day_of_month.
24752471
24762472
Parameters
24772473
----------
@@ -2704,8 +2700,9 @@ cdef class WeekOfMonth(WeekOfMonthMixin):
27042700

27052701
cdef class LastWeekOfMonth(WeekOfMonthMixin):
27062702
"""
2707-
Describes monthly dates in last week of month like "the last Tuesday of
2708-
each month".
2703+
Describes monthly dates in last week of month.
2704+
2705+
For example "the last Tuesday of each month".
27092706
27102707
Parameters
27112708
----------
@@ -2991,8 +2988,9 @@ cdef class FY5253(FY5253Mixin):
29912988

29922989
cdef class FY5253Quarter(FY5253Mixin):
29932990
"""
2994-
DateOffset increments between business quarter dates
2995-
for 52-53 week fiscal year (also known as a 4-4-5 calendar).
2991+
DateOffset increments between business quarter dates for 52-53 week fiscal year.
2992+
2993+
Also known as a 4-4-5 calendar.
29962994
29972995
It is used by companies that desire that their
29982996
fiscal year always end on the same day of the week.
@@ -3602,8 +3600,7 @@ def _get_offset(name: str) -> BaseOffset:
36023600

36033601
cpdef to_offset(freq):
36043602
"""
3605-
Return DateOffset object from string or tuple representation
3606-
or datetime.timedelta object.
3603+
Return DateOffset object from string or datetime.timedelta object.
36073604
36083605
Parameters
36093606
----------

0 commit comments

Comments
 (0)