Skip to content

Commit 5ede7e5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into as_index_false
2 parents 64bacc2 + 1ce9f0c commit 5ede7e5

30 files changed

+467
-324
lines changed

doc/source/reference/offset_frequency.rst

+37
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Properties
2525
DateOffset.nanos
2626
DateOffset.normalize
2727
DateOffset.rule_code
28+
DateOffset.n
2829

2930
Methods
3031
~~~~~~~
@@ -57,6 +58,7 @@ Properties
5758
BusinessDay.nanos
5859
BusinessDay.normalize
5960
BusinessDay.rule_code
61+
BusinessDay.n
6062

6163
Methods
6264
~~~~~~~
@@ -90,6 +92,7 @@ Properties
9092
BusinessHour.nanos
9193
BusinessHour.normalize
9294
BusinessHour.rule_code
95+
BusinessHour.n
9396

9497
Methods
9598
~~~~~~~
@@ -122,6 +125,7 @@ Properties
122125
CustomBusinessDay.nanos
123126
CustomBusinessDay.normalize
124127
CustomBusinessDay.rule_code
128+
CustomBusinessDay.n
125129

126130
Methods
127131
~~~~~~~
@@ -154,6 +158,7 @@ Properties
154158
CustomBusinessHour.nanos
155159
CustomBusinessHour.normalize
156160
CustomBusinessHour.rule_code
161+
CustomBusinessHour.n
157162

158163
Methods
159164
~~~~~~~
@@ -186,6 +191,7 @@ Properties
186191
MonthOffset.nanos
187192
MonthOffset.normalize
188193
MonthOffset.rule_code
194+
MonthOffset.n
189195

190196
Methods
191197
~~~~~~~
@@ -219,6 +225,7 @@ Properties
219225
MonthEnd.nanos
220226
MonthEnd.normalize
221227
MonthEnd.rule_code
228+
MonthEnd.n
222229

223230
Methods
224231
~~~~~~~
@@ -252,6 +259,7 @@ Properties
252259
MonthBegin.nanos
253260
MonthBegin.normalize
254261
MonthBegin.rule_code
262+
MonthBegin.n
255263

256264
Methods
257265
~~~~~~~
@@ -285,6 +293,7 @@ Properties
285293
BusinessMonthEnd.nanos
286294
BusinessMonthEnd.normalize
287295
BusinessMonthEnd.rule_code
296+
BusinessMonthEnd.n
288297

289298
Methods
290299
~~~~~~~
@@ -318,6 +327,7 @@ Properties
318327
BusinessMonthBegin.nanos
319328
BusinessMonthBegin.normalize
320329
BusinessMonthBegin.rule_code
330+
BusinessMonthBegin.n
321331

322332
Methods
323333
~~~~~~~
@@ -352,6 +362,7 @@ Properties
352362
CustomBusinessMonthEnd.nanos
353363
CustomBusinessMonthEnd.normalize
354364
CustomBusinessMonthEnd.rule_code
365+
CustomBusinessMonthEnd.n
355366

356367
Methods
357368
~~~~~~~
@@ -385,6 +396,7 @@ Properties
385396
CustomBusinessMonthBegin.nanos
386397
CustomBusinessMonthBegin.normalize
387398
CustomBusinessMonthBegin.rule_code
399+
CustomBusinessMonthBegin.n
388400

389401
Methods
390402
~~~~~~~
@@ -417,6 +429,7 @@ Properties
417429
SemiMonthOffset.nanos
418430
SemiMonthOffset.normalize
419431
SemiMonthOffset.rule_code
432+
SemiMonthOffset.n
420433

421434
Methods
422435
~~~~~~~
@@ -450,6 +463,7 @@ Properties
450463
SemiMonthEnd.nanos
451464
SemiMonthEnd.normalize
452465
SemiMonthEnd.rule_code
466+
SemiMonthEnd.n
453467

454468
Methods
455469
~~~~~~~
@@ -483,6 +497,7 @@ Properties
483497
SemiMonthBegin.nanos
484498
SemiMonthBegin.normalize
485499
SemiMonthBegin.rule_code
500+
SemiMonthBegin.n
486501

487502
Methods
488503
~~~~~~~
@@ -516,6 +531,7 @@ Properties
516531
Week.nanos
517532
Week.normalize
518533
Week.rule_code
534+
Week.n
519535

520536
Methods
521537
~~~~~~~
@@ -549,6 +565,7 @@ Properties
549565
WeekOfMonth.nanos
550566
WeekOfMonth.normalize
551567
WeekOfMonth.rule_code
568+
WeekOfMonth.n
552569

553570
Methods
554571
~~~~~~~
@@ -581,6 +598,7 @@ Properties
581598
LastWeekOfMonth.nanos
582599
LastWeekOfMonth.normalize
583600
LastWeekOfMonth.rule_code
601+
LastWeekOfMonth.n
584602

585603
Methods
586604
~~~~~~~
@@ -613,6 +631,7 @@ Properties
613631
QuarterOffset.nanos
614632
QuarterOffset.normalize
615633
QuarterOffset.rule_code
634+
QuarterOffset.n
616635

617636
Methods
618637
~~~~~~~
@@ -646,6 +665,7 @@ Properties
646665
BQuarterEnd.nanos
647666
BQuarterEnd.normalize
648667
BQuarterEnd.rule_code
668+
BQuarterEnd.n
649669

650670
Methods
651671
~~~~~~~
@@ -679,6 +699,7 @@ Properties
679699
BQuarterBegin.nanos
680700
BQuarterBegin.normalize
681701
BQuarterBegin.rule_code
702+
BQuarterBegin.n
682703

683704
Methods
684705
~~~~~~~
@@ -712,6 +733,7 @@ Properties
712733
QuarterEnd.nanos
713734
QuarterEnd.normalize
714735
QuarterEnd.rule_code
736+
QuarterEnd.n
715737

716738
Methods
717739
~~~~~~~
@@ -745,6 +767,7 @@ Properties
745767
QuarterBegin.nanos
746768
QuarterBegin.normalize
747769
QuarterBegin.rule_code
770+
QuarterBegin.n
748771

749772
Methods
750773
~~~~~~~
@@ -778,6 +801,7 @@ Properties
778801
YearOffset.nanos
779802
YearOffset.normalize
780803
YearOffset.rule_code
804+
YearOffset.n
781805

782806
Methods
783807
~~~~~~~
@@ -811,6 +835,7 @@ Properties
811835
BYearEnd.nanos
812836
BYearEnd.normalize
813837
BYearEnd.rule_code
838+
BYearEnd.n
814839

815840
Methods
816841
~~~~~~~
@@ -844,6 +869,7 @@ Properties
844869
BYearBegin.nanos
845870
BYearBegin.normalize
846871
BYearBegin.rule_code
872+
BYearBegin.n
847873

848874
Methods
849875
~~~~~~~
@@ -877,6 +903,7 @@ Properties
877903
YearEnd.nanos
878904
YearEnd.normalize
879905
YearEnd.rule_code
906+
YearEnd.n
880907

881908
Methods
882909
~~~~~~~
@@ -910,6 +937,7 @@ Properties
910937
YearBegin.nanos
911938
YearBegin.normalize
912939
YearBegin.rule_code
940+
YearBegin.n
913941

914942
Methods
915943
~~~~~~~
@@ -943,6 +971,7 @@ Properties
943971
FY5253.nanos
944972
FY5253.normalize
945973
FY5253.rule_code
974+
FY5253.n
946975

947976
Methods
948977
~~~~~~~
@@ -977,6 +1006,7 @@ Properties
9771006
FY5253Quarter.nanos
9781007
FY5253Quarter.normalize
9791008
FY5253Quarter.rule_code
1009+
FY5253Quarter.n
9801010

9811011
Methods
9821012
~~~~~~~
@@ -1011,6 +1041,7 @@ Properties
10111041
Easter.nanos
10121042
Easter.normalize
10131043
Easter.rule_code
1044+
Easter.n
10141045

10151046
Methods
10161047
~~~~~~~
@@ -1317,6 +1348,7 @@ Properties
13171348
BDay.normalize
13181349
BDay.offset
13191350
BDay.rule_code
1351+
BDay.n
13201352

13211353
Methods
13221354
~~~~~~~
@@ -1353,6 +1385,7 @@ Properties
13531385
BMonthEnd.nanos
13541386
BMonthEnd.normalize
13551387
BMonthEnd.rule_code
1388+
BMonthEnd.n
13561389

13571390
Methods
13581391
~~~~~~~
@@ -1389,6 +1422,7 @@ Properties
13891422
BMonthBegin.nanos
13901423
BMonthBegin.normalize
13911424
BMonthBegin.rule_code
1425+
BMonthBegin.n
13921426

13931427
Methods
13941428
~~~~~~~
@@ -1429,6 +1463,7 @@ Properties
14291463
CBMonthEnd.normalize
14301464
CBMonthEnd.offset
14311465
CBMonthEnd.rule_code
1466+
CBMonthEnd.n
14321467

14331468
Methods
14341469
~~~~~~~
@@ -1469,6 +1504,7 @@ Properties
14691504
CBMonthBegin.normalize
14701505
CBMonthBegin.offset
14711506
CBMonthBegin.rule_code
1507+
CBMonthBegin.n
14721508

14731509
Methods
14741510
~~~~~~~
@@ -1506,6 +1542,7 @@ Properties
15061542
CDay.normalize
15071543
CDay.offset
15081544
CDay.rule_code
1545+
CDay.n
15091546

15101547
Methods
15111548
~~~~~~~

doc/source/whatsnew/v1.1.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ Sparse
910910
^^^^^^
911911
- Creating a :class:`SparseArray` from timezone-aware dtype will issue a warning before dropping timezone information, instead of doing so silently (:issue:`32501`)
912912
- Bug in :meth:`arrays.SparseArray.from_spmatrix` wrongly read scipy sparse matrix (:issue:`31991`)
913-
-
913+
- Bug in :meth:`Series.sum` with ``SparseArray`` raises ``TypeError`` (:issue:`25777`)
914914

915915
ExtensionArray
916916
^^^^^^^^^^^^^^

pandas/_libs/tslibs/base.pxd

-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ cdef class ABCTimestamp(datetime):
88
pass
99

1010

11-
cdef class ABCTick:
12-
pass
13-
14-
1511
cdef class ABCPeriod:
1612
pass
1713

1814

19-
cdef bint is_tick_object(object obj)
2015
cdef bint is_period_object(object obj)

pandas/_libs/tslibs/base.pyx

-8
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,5 @@ cdef class ABCPeriod:
2020
pass
2121

2222

23-
cdef class ABCTick:
24-
pass
25-
26-
27-
cdef bint is_tick_object(object obj):
28-
return isinstance(obj, ABCTick)
29-
30-
3123
cdef bint is_period_object(object obj):
3224
return isinstance(obj, ABCPeriod)

pandas/_libs/tslibs/frequencies.pxd

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cdef dict attrname_to_abbrevs
2+
13
cpdef str get_rule_month(object source, str default=*)
24

35
cpdef get_freq_code(freqstr)

pandas/_libs/tslibs/frequencies.pyx

+42
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,50 @@ _lite_rule_alias = {
124124

125125
_dont_uppercase = {'MS', 'ms'}
126126

127+
# Map attribute-name resolutions to resolution abbreviations
128+
_attrname_to_abbrevs = {
129+
"year": "A",
130+
"quarter": "Q",
131+
"month": "M",
132+
"day": "D",
133+
"hour": "H",
134+
"minute": "T",
135+
"second": "S",
136+
"millisecond": "L",
137+
"microsecond": "U",
138+
"nanosecond": "N",
139+
}
140+
cdef dict attrname_to_abbrevs = _attrname_to_abbrevs
141+
142+
127143
# ----------------------------------------------------------------------
128144

145+
def get_freq_group(freq) -> int:
146+
"""
147+
Return frequency code group of given frequency str or offset.
148+
149+
Examples
150+
--------
151+
>>> get_freq_group('W-MON')
152+
4000
153+
154+
>>> get_freq_group('W-FRI')
155+
4000
156+
"""
157+
if is_offset_object(freq):
158+
freq = freq.rule_code
159+
160+
if isinstance(freq, str):
161+
freq = attrname_to_abbrevs.get(freq, freq)
162+
base, mult = get_freq_code(freq)
163+
freq = base
164+
elif isinstance(freq, int):
165+
pass
166+
else:
167+
raise ValueError('input must be str, offset or int')
168+
return (freq // 1000) * 1000
169+
170+
129171
cpdef get_freq_code(freqstr):
130172
"""
131173
Return freq str or tuple to freq code and stride (mult)

pandas/_libs/tslibs/offsets.pxd

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
cdef to_offset(object obj)
22
cdef bint is_offset_object(object obj)
3+
cdef bint is_tick_object(object obj)

0 commit comments

Comments
 (0)