Skip to content

Commit b55b270

Browse files
committed
Merge remote-tracking branch 'upstream/master' into Rt05
* upstream/master: DOC: Fix validation type error SA05 (pandas-dev#25208) REF: Add more pytest idiom to test_holiday.py (pandas-dev#25204) DOC/CLN: Fix errors in Series docstrings (pandas-dev#24945) TST: follow-up to Test nested pandas array pandas-dev#24993 (pandas-dev#25155) modernize compat imports (pandas-dev#25192) fix MacPython pandas-wheels failure (pandas-dev#25186) BUG: DataFrame.merge(suffixes=) does not respect None (pandas-dev#24819) DEPR: remove PanelGroupBy, disable DataFrame.to_panel (pandas-dev#25047) DOC: update docstring for series.nunique (pandas-dev#25116) CLN: Use ABCs in set_index (pandas-dev#25128) BLD: pin cython language level to '2' (pandas-dev#25145) DOC: Updates to Timestamp document (pandas-dev#25163) STY: use pytest.raises context manager (indexes/multi) (pandas-dev#25175) Fixed tuple to List Conversion in Dataframe class (pandas-dev#25089)
2 parents 163e9e3 + 683c7b5 commit b55b270

Some content is hidden

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

92 files changed

+1621
-1917
lines changed

ci/code_checks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ fi
240240
### DOCSTRINGS ###
241241
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
242242

243-
MSG='Validate docstrings (GL06, GL07, GL09, SS04, SS05, PR03, PR05, EX04, RT04, RT05)' ; echo $MSG
244-
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,SS05,PR03,PR05,EX04,RT04,RT05
243+
MSG='Validate docstrings (GL06, GL07, GL09, SS04, SS05, PR03, PR05, EX04, RT04, RT05, SA05)' ; echo $MSG
244+
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,SS05,PR03,PR05,EX04,RT04,RT05,SA05
245245
RET=$(($RET + $?)) ; echo $MSG "DONE"
246246

247247
fi

doc/source/whatsnew/v0.24.2.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Fixed Regressions
2222

2323
- Fixed regression in :meth:`DataFrame.all` and :meth:`DataFrame.any` where ``bool_only=True`` was ignored (:issue:`25101`)
2424

25+
- Fixed issue in ``DataFrame`` construction with passing a mixed list of mixed types could segfault. (:issue:`25075`)
26+
2527
.. _whatsnew_0242.enhancements:
2628

2729
Enhancements
@@ -94,4 +96,4 @@ Bug Fixes
9496
Contributors
9597
~~~~~~~~~~~~
9698

97-
.. contributors:: v0.24.1..v0.24.2
99+
.. contributors:: v0.24.1..v0.24.2

doc/source/whatsnew/v0.25.0.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Deprecations
5151

5252
Removal of prior version deprecations/changes
5353
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54-
54+
- Removed (parts of) :class:`Panel` (:issue:`25047`)
5555
-
5656
-
5757
-
@@ -181,6 +181,7 @@ Groupby/Resample/Rolling
181181
Reshaping
182182
^^^^^^^^^
183183

184+
- Bug in :func:`pandas.merge` adds a string of ``None`` if ``None`` is assigned in suffixes instead of remain the column name as-is (:issue:`24782`).
184185
- Bug in :func:`merge` when merging by index name would sometimes result in an incorrectly numbered index (:issue:`24212`)
185186
- :func:`to_records` now accepts dtypes to its `column_dtypes` parameter (:issue:`24895`)
186187
-

pandas/_libs/lib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,7 @@ def to_object_array(rows: object, int min_width=0):
22772277
result = np.empty((n, k), dtype=object)
22782278

22792279
for i in range(n):
2280-
row = <list>input_rows[i]
2280+
row = list(input_rows[i])
22812281

22822282
for j in range(len(row)):
22832283
result[i, j] = row[j]

pandas/_libs/tslibs/timestamps.pyx

+45
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ cdef class _Timestamp(datetime):
504504

505505
@property
506506
def asm8(self):
507+
"""
508+
Return numpy datetime64 format in nanoseconds.
509+
"""
507510
return np.datetime64(self.value, 'ns')
508511

509512
@property
@@ -570,15 +573,18 @@ class Timestamp(_Timestamp):
570573
Using the primary calling convention:
571574
572575
This converts a datetime-like string
576+
573577
>>> pd.Timestamp('2017-01-01T12')
574578
Timestamp('2017-01-01 12:00:00')
575579
576580
This converts a float representing a Unix epoch in units of seconds
581+
577582
>>> pd.Timestamp(1513393355.5, unit='s')
578583
Timestamp('2017-12-16 03:02:35.500000')
579584
580585
This converts an int representing a Unix-epoch in units of seconds
581586
and for a particular timezone
587+
582588
>>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific')
583589
Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific')
584590
@@ -934,6 +940,9 @@ class Timestamp(_Timestamp):
934940

935941
@property
936942
def dayofweek(self):
943+
"""
944+
Return day of whe week.
945+
"""
937946
return self.weekday()
938947

939948
def day_name(self, locale=None):
@@ -983,72 +992,108 @@ class Timestamp(_Timestamp):
983992

984993
@property
985994
def dayofyear(self):
995+
"""
996+
Return the day of the year.
997+
"""
986998
return ccalendar.get_day_of_year(self.year, self.month, self.day)
987999

9881000
@property
9891001
def week(self):
1002+
"""
1003+
Return the week number of the year.
1004+
"""
9901005
return ccalendar.get_week_of_year(self.year, self.month, self.day)
9911006

9921007
weekofyear = week
9931008

9941009
@property
9951010
def quarter(self):
1011+
"""
1012+
Return the quarter of the year.
1013+
"""
9961014
return ((self.month - 1) // 3) + 1
9971015

9981016
@property
9991017
def days_in_month(self):
1018+
"""
1019+
Return the number of days in the month.
1020+
"""
10001021
return ccalendar.get_days_in_month(self.year, self.month)
10011022

10021023
daysinmonth = days_in_month
10031024

10041025
@property
10051026
def freqstr(self):
1027+
"""
1028+
Return the total number of days in the month.
1029+
"""
10061030
return getattr(self.freq, 'freqstr', self.freq)
10071031

10081032
@property
10091033
def is_month_start(self):
1034+
"""
1035+
Return True if date is first day of month.
1036+
"""
10101037
if self.freq is None:
10111038
# fast-path for non-business frequencies
10121039
return self.day == 1
10131040
return self._get_start_end_field('is_month_start')
10141041

10151042
@property
10161043
def is_month_end(self):
1044+
"""
1045+
Return True if date is last day of month.
1046+
"""
10171047
if self.freq is None:
10181048
# fast-path for non-business frequencies
10191049
return self.day == self.days_in_month
10201050
return self._get_start_end_field('is_month_end')
10211051

10221052
@property
10231053
def is_quarter_start(self):
1054+
"""
1055+
Return True if date is first day of the quarter.
1056+
"""
10241057
if self.freq is None:
10251058
# fast-path for non-business frequencies
10261059
return self.day == 1 and self.month % 3 == 1
10271060
return self._get_start_end_field('is_quarter_start')
10281061

10291062
@property
10301063
def is_quarter_end(self):
1064+
"""
1065+
Return True if date is last day of the quarter.
1066+
"""
10311067
if self.freq is None:
10321068
# fast-path for non-business frequencies
10331069
return (self.month % 3) == 0 and self.day == self.days_in_month
10341070
return self._get_start_end_field('is_quarter_end')
10351071

10361072
@property
10371073
def is_year_start(self):
1074+
"""
1075+
Return True if date is first day of the year.
1076+
"""
10381077
if self.freq is None:
10391078
# fast-path for non-business frequencies
10401079
return self.day == self.month == 1
10411080
return self._get_start_end_field('is_year_start')
10421081

10431082
@property
10441083
def is_year_end(self):
1084+
"""
1085+
Return True if date is last day of the year.
1086+
"""
10451087
if self.freq is None:
10461088
# fast-path for non-business frequencies
10471089
return self.month == 12 and self.day == 31
10481090
return self._get_start_end_field('is_year_end')
10491091

10501092
@property
10511093
def is_leap_year(self):
1094+
"""
1095+
Return True if year is a leap year.
1096+
"""
10521097
return bool(ccalendar.is_leapyear(self.year))
10531098

10541099
def tz_localize(self, tz, ambiguous='raise', nonexistent='raise',

pandas/compat/__init__.py

-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* lists: lrange(), lmap(), lzip(), lfilter()
1010
* unicode: u() [no unicode builtin in Python 3]
1111
* longs: long (int in Python 3)
12-
* callable
1312
* iterable method compatibility: iteritems, iterkeys, itervalues
1413
* Uses the original method if available, otherwise uses items, keys, values.
1514
* types:
@@ -378,14 +377,6 @@ class ResourceWarning(Warning):
378377
string_and_binary_types = string_types + (binary_type,)
379378

380379

381-
try:
382-
# callable reintroduced in later versions of Python
383-
callable = callable
384-
except NameError:
385-
def callable(obj):
386-
return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
387-
388-
389380
if PY2:
390381
# In PY2 functools.wraps doesn't provide metadata pytest needs to generate
391382
# decorated tests using parametrization. See pytest GH issue #2782
@@ -411,8 +402,6 @@ def wrapper(cls):
411402
return metaclass(cls.__name__, cls.__bases__, orig_vars)
412403
return wrapper
413404

414-
from collections import OrderedDict, Counter
415-
416405
if PY3:
417406
def raise_with_traceback(exc, traceback=Ellipsis):
418407
if traceback == Ellipsis:

pandas/compat/numpy/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
_np_version_under1p13 = _nlv < LooseVersion('1.13')
1313
_np_version_under1p14 = _nlv < LooseVersion('1.14')
1414
_np_version_under1p15 = _nlv < LooseVersion('1.15')
15+
_np_version_under1p16 = _nlv < LooseVersion('1.16')
1516

1617

1718
if _nlv < '1.12':
@@ -64,5 +65,6 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
6465
__all__ = ['np',
6566
'_np_version_under1p13',
6667
'_np_version_under1p14',
67-
'_np_version_under1p15'
68+
'_np_version_under1p15',
69+
'_np_version_under1p16'
6870
]

pandas/compat/numpy/function.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
and methods that are spread throughout the codebase. This module will make it
1818
easier to adjust to future upstream changes in the analogous numpy signatures.
1919
"""
20+
from collections import OrderedDict
2021

2122
from numpy import ndarray
2223

23-
from pandas.compat import OrderedDict
2424
from pandas.errors import UnsupportedFunctionCall
2525
from pandas.util._validators import (
2626
validate_args, validate_args_and_kwargs, validate_kwargs)

pandas/core/algorithms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ def unique(values):
298298
299299
See Also
300300
--------
301-
pandas.Index.unique
302-
pandas.Series.unique
301+
Index.unique
302+
Series.unique
303303
304304
Examples
305305
--------

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class Categorical(ExtensionArray, PandasObject):
276276
277277
See Also
278278
--------
279-
pandas.api.types.CategoricalDtype : Type for categorical data.
279+
api.types.CategoricalDtype : Type for categorical data.
280280
CategoricalIndex : An Index with an underlying ``Categorical``.
281281
282282
Notes

pandas/core/base.py

+27-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""
22
Base and utility classes for pandas objects.
33
"""
4+
from collections import OrderedDict
45
import textwrap
56
import warnings
67

78
import numpy as np
89

910
import pandas._libs.lib as lib
1011
import pandas.compat as compat
11-
from pandas.compat import PYPY, OrderedDict, builtins, map, range
12+
from pandas.compat import PYPY, builtins, map, range
1213
from pandas.compat.numpy import function as nv
1314
from pandas.errors import AbstractMethodError
1415
from pandas.util._decorators import Appender, Substitution, cache_readonly
@@ -376,7 +377,7 @@ def nested_renaming_depr(level=4):
376377
# eg. {'A' : ['mean']}, normalize all to
377378
# be list-likes
378379
if any(is_aggregator(x) for x in compat.itervalues(arg)):
379-
new_arg = compat.OrderedDict()
380+
new_arg = OrderedDict()
380381
for k, v in compat.iteritems(arg):
381382
if not isinstance(v, (tuple, list, dict)):
382383
new_arg[k] = [v]
@@ -444,22 +445,22 @@ def _agg(arg, func):
444445
run the aggregations over the arg with func
445446
return an OrderedDict
446447
"""
447-
result = compat.OrderedDict()
448+
result = OrderedDict()
448449
for fname, agg_how in compat.iteritems(arg):
449450
result[fname] = func(fname, agg_how)
450451
return result
451452

452453
# set the final keys
453454
keys = list(compat.iterkeys(arg))
454-
result = compat.OrderedDict()
455+
result = OrderedDict()
455456

456457
# nested renamer
457458
if is_nested_renamer:
458459
result = list(_agg(arg, _agg_1dim).values())
459460

460461
if all(isinstance(r, dict) for r in result):
461462

462-
result, results = compat.OrderedDict(), result
463+
result, results = OrderedDict(), result
463464
for r in results:
464465
result.update(r)
465466
keys = list(compat.iterkeys(result))
@@ -1323,12 +1324,31 @@ def nunique(self, dropna=True):
13231324
13241325
Parameters
13251326
----------
1326-
dropna : boolean, default True
1327+
dropna : bool, default True
13271328
Don't include NaN in the count.
13281329
13291330
Returns
13301331
-------
1331-
nunique : int
1332+
int
1333+
1334+
See Also
1335+
--------
1336+
DataFrame.nunique: Method nunique for DataFrame.
1337+
Series.count: Count non-NA/null observations in the Series.
1338+
1339+
Examples
1340+
--------
1341+
>>> s = pd.Series([1, 3, 5, 7, 7])
1342+
>>> s
1343+
0 1
1344+
1 3
1345+
2 5
1346+
3 7
1347+
4 7
1348+
dtype: int64
1349+
1350+
>>> s.nunique()
1351+
4
13321352
"""
13331353
uniqs = self.unique()
13341354
n = len(uniqs)

pandas/core/common.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import collections
8+
from collections import OrderedDict
89
from datetime import datetime, timedelta
910
from functools import partial
1011
import inspect
@@ -13,7 +14,7 @@
1314

1415
from pandas._libs import lib, tslibs
1516
import pandas.compat as compat
16-
from pandas.compat import PY36, OrderedDict, iteritems
17+
from pandas.compat import PY36, iteritems
1718

1819
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
1920
from pandas.core.dtypes.common import (

0 commit comments

Comments
 (0)