Skip to content

Commit a1f80ee

Browse files
committed
Merge remote-tracking branch 'upstream/master' into docfix-multiindex-set_levels
2 parents 62b1645 + ea2e26a commit a1f80ee

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

+285
-726
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88

99
env:
1010
ENV_FILE: environment.yml
11-
# TODO: remove export PATH=... in each step once this works
12-
# PATH: $HOME/miniconda3/bin:$PATH
1311

1412
jobs:
1513
checks:
@@ -20,68 +18,61 @@ jobs:
2018
- name: Checkout
2119
uses: actions/checkout@v1
2220

21+
- name: Setting conda path
22+
run: echo "::set-env name=PATH::${HOME}/miniconda3/bin:${PATH}"
23+
2324
- name: Looking for unwanted patterns
2425
run: ci/code_checks.sh patterns
2526
if: true
2627

2728
- name: Setup environment and build pandas
28-
run: |
29-
export PATH=$HOME/miniconda3/bin:$PATH
30-
ci/setup_env.sh
29+
run: ci/setup_env.sh
3130
if: true
3231

3332
- name: Linting
3433
run: |
35-
export PATH=$HOME/miniconda3/bin:$PATH
3634
source activate pandas-dev
3735
ci/code_checks.sh lint
3836
if: true
3937

4038
- name: Dependencies consistency
4139
run: |
42-
export PATH=$HOME/miniconda3/bin:$PATH
4340
source activate pandas-dev
4441
ci/code_checks.sh dependencies
4542
if: true
4643

4744
- name: Checks on imported code
4845
run: |
49-
export PATH=$HOME/miniconda3/bin:$PATH
5046
source activate pandas-dev
5147
ci/code_checks.sh code
5248
if: true
5349

5450
- name: Running doctests
5551
run: |
56-
export PATH=$HOME/miniconda3/bin:$PATH
5752
source activate pandas-dev
5853
ci/code_checks.sh doctests
5954
if: true
6055

6156
- name: Docstring validation
6257
run: |
63-
export PATH=$HOME/miniconda3/bin:$PATH
6458
source activate pandas-dev
6559
ci/code_checks.sh docstrings
6660
if: true
6761

6862
- name: Typing validation
6963
run: |
70-
export PATH=$HOME/miniconda3/bin:$PATH
7164
source activate pandas-dev
7265
ci/code_checks.sh typing
7366
if: true
7467

7568
- name: Testing docstring validation script
7669
run: |
77-
export PATH=$HOME/miniconda3/bin:$PATH
7870
source activate pandas-dev
7971
pytest --capture=no --strict scripts
8072
if: true
8173

8274
- name: Running benchmarks
8375
run: |
84-
export PATH=$HOME/miniconda3/bin:$PATH
8576
source activate pandas-dev
8677
cd asv_bench
8778
asv check -E existing

asv_bench/benchmarks/timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class InferFreq:
113113
def setup(self, freq):
114114
if freq is None:
115115
self.idx = date_range(start="1/1/1700", freq="D", periods=10000)
116-
self.idx.freq = None
116+
self.idx._data._freq = None
117117
else:
118118
self.idx = date_range(start="1/1/1700", freq=freq, periods=10000)
119119

doc/redirects.csv

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,8 @@ generated/pandas.DataFrame.from_csv,../reference/api/pandas.DataFrame.from_csv
357357
generated/pandas.DataFrame.from_dict,../reference/api/pandas.DataFrame.from_dict
358358
generated/pandas.DataFrame.from_items,../reference/api/pandas.DataFrame.from_items
359359
generated/pandas.DataFrame.from_records,../reference/api/pandas.DataFrame.from_records
360-
generated/pandas.DataFrame.ftypes,../reference/api/pandas.DataFrame.ftypes
361360
generated/pandas.DataFrame.ge,../reference/api/pandas.DataFrame.ge
362361
generated/pandas.DataFrame.get_dtype_counts,../reference/api/pandas.DataFrame.get_dtype_counts
363-
generated/pandas.DataFrame.get_ftype_counts,../reference/api/pandas.DataFrame.get_ftype_counts
364362
generated/pandas.DataFrame.get,../reference/api/pandas.DataFrame.get
365363
generated/pandas.DataFrame.get_value,../reference/api/pandas.DataFrame.get_value
366364
generated/pandas.DataFrame.get_values,../reference/api/pandas.DataFrame.get_values
@@ -883,10 +881,8 @@ generated/pandas.Panel.first_valid_index,../reference/api/pandas.Panel.first_val
883881
generated/pandas.Panel.floordiv,../reference/api/pandas.Panel.floordiv
884882
generated/pandas.Panel.from_dict,../reference/api/pandas.Panel.from_dict
885883
generated/pandas.Panel.fromDict,../reference/api/pandas.Panel.fromDict
886-
generated/pandas.Panel.ftypes,../reference/api/pandas.Panel.ftypes
887884
generated/pandas.Panel.ge,../reference/api/pandas.Panel.ge
888885
generated/pandas.Panel.get_dtype_counts,../reference/api/pandas.Panel.get_dtype_counts
889-
generated/pandas.Panel.get_ftype_counts,../reference/api/pandas.Panel.get_ftype_counts
890886
generated/pandas.Panel.get,../reference/api/pandas.Panel.get
891887
generated/pandas.Panel.get_value,../reference/api/pandas.Panel.get_value
892888
generated/pandas.Panel.get_values,../reference/api/pandas.Panel.get_values
@@ -1223,11 +1219,8 @@ generated/pandas.Series.flags,../reference/api/pandas.Series.flags
12231219
generated/pandas.Series.floordiv,../reference/api/pandas.Series.floordiv
12241220
generated/pandas.Series.from_array,../reference/api/pandas.Series.from_array
12251221
generated/pandas.Series.from_csv,../reference/api/pandas.Series.from_csv
1226-
generated/pandas.Series.ftype,../reference/api/pandas.Series.ftype
1227-
generated/pandas.Series.ftypes,../reference/api/pandas.Series.ftypes
12281222
generated/pandas.Series.ge,../reference/api/pandas.Series.ge
12291223
generated/pandas.Series.get_dtype_counts,../reference/api/pandas.Series.get_dtype_counts
1230-
generated/pandas.Series.get_ftype_counts,../reference/api/pandas.Series.get_ftype_counts
12311224
generated/pandas.Series.get,../reference/api/pandas.Series.get
12321225
generated/pandas.Series.get_value,../reference/api/pandas.Series.get_value
12331226
generated/pandas.Series.get_values,../reference/api/pandas.Series.get_values

doc/source/reference/frame.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Attributes and underlying data
2828
:toctree: api/
2929

3030
DataFrame.dtypes
31-
DataFrame.ftypes
3231
DataFrame.get_dtype_counts
3332
DataFrame.select_dtypes
3433
DataFrame.values

doc/source/reference/series.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Attributes
2929
Series.array
3030
Series.values
3131
Series.dtype
32-
Series.ftype
3332
Series.shape
3433
Series.nbytes
3534
Series.ndim
@@ -43,7 +42,6 @@ Attributes
4342
Series.flags
4443
Series.empty
4544
Series.dtypes
46-
Series.ftypes
4745
Series.data
4846
Series.name
4947
Series.put

doc/source/user_guide/timeseries.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ There are several time/date properties that one can access from ``Timestamp`` or
772772
week,"The week ordinal of the year"
773773
dayofweek,"The number of the day of the week with Monday=0, Sunday=6"
774774
weekday,"The number of the day of the week with Monday=0, Sunday=6"
775-
weekday_name,"The name of the day in a week (ex: Friday)"
776775
quarter,"Quarter of the date: Jan-Mar = 1, Apr-Jun = 2, etc."
777776
days_in_month,"The number of days in the month of the datetime"
778777
is_month_start,"Logical indicating if first day of month (defined by frequency)"
@@ -1591,18 +1590,18 @@ labels.
15911590
15921591
s = pd.date_range('2000-01-01', '2000-01-05').to_series()
15931592
s.iloc[2] = pd.NaT
1594-
s.dt.weekday_name
1593+
s.dt.day_name()
15951594
15961595
# default: label='left', closed='left'
1597-
s.resample('B').last().dt.weekday_name
1596+
s.resample('B').last().dt.day_name()
15981597
15991598
Notice how the value for Sunday got pulled back to the previous Friday.
16001599
To get the behavior where the value for Sunday is pushed to Monday, use
16011600
instead
16021601

16031602
.. ipython:: python
16041603
1605-
s.resample('B', label='right', closed='right').last().dt.weekday_name
1604+
s.resample('B', label='right', closed='right').last().dt.day_name()
16061605
16071606
The ``axis`` parameter can be set to 0 or 1 and allows you to resample the
16081607
specified axis for a ``DataFrame``.

doc/source/whatsnew/v1.0.0.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,14 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
394394
**Other removals**
395395

396396
- Floordiv of integer-dtyped array by :class:`Timedelta` now raises ``TypeError`` (:issue:`21036`)
397+
- :func:`pandas.api.types.infer_dtype` argument ``skipna`` defaults to ``True`` instead of ``False`` (:issue:`24050`)
397398
- Removed the previously deprecated :meth:`Index.summary` (:issue:`18217`)
398399
- Removed the previously deprecated "fastpath" keyword from the :class:`Index` constructor (:issue:`23110`)
399400
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
400401
- Changed the the default value of `inplace` in :meth:`DataFrame.set_index` and :meth:`Series.set_axis`. It now defaults to False (:issue:`27600`)
402+
- Removed the previously deprecated :attr:`Series.cat.categorical`, :attr:`Series.cat.index`, :attr:`Series.cat.name` (:issue:`24751`)
401403
- Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`)
404+
- Passing ``datetime64`` data to :class:`TimedeltaIndex` or ``timedelta64`` data to ``DatetimeIndex`` now raises ``TypeError`` (:issue:`23539`, :issue:`23937`)
402405
- A tuple passed to :meth:`DataFrame.groupby` is now exclusively treated as a single key (:issue:`18314`)
403406
- Removed :meth:`Series.from_array` (:issue:`18258`)
404407
- Removed :meth:`DataFrame.from_items` (:issue:`18458`)
@@ -432,6 +435,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
432435
- Removed the previously deprecated :meth:`Series.valid`; use :meth:`Series.dropna` instead (:issue:`18800`)
433436
- Removed the previously properties :attr:`DataFrame.is_copy`, :attr:`Series.is_copy` (:issue:`18812`)
434437
- Removed the previously deprecated :meth:`DataFrame.get_ftype_counts`, :meth:`Series.get_ftype_counts` (:issue:`18243`)
438+
- Removed the previously deprecated :meth:`DataFrame.ftypes`, :meth:`Series.ftypes`, :meth:`Series.ftype` (:issue:`26744`)
435439
- Removed the previously deprecated :meth:`Index.get_duplicated`, use ``idx[idx.duplicated()].unique()`` instead (:issue:`20239`)
436440
- Removed the previously deprecated :meth:`Series.clip_upper`, :meth:`Series.clip_lower`, :meth:`DataFrame.clip_upper`, :meth:`DataFrame.clip_lower` (:issue:`24203`)
437441
- Removed the ability to alter :attr:`DatetimeIndex.freq`, :attr:`TimedeltaIndex.freq`, or :attr:`PeriodIndex.freq` (:issue:`20772`)
@@ -445,6 +449,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
445449
- Removed previously deprecated keyword "n" from :meth:`DatetimeIndex.shift`, :meth:`TimedeltaIndex.shift`, :meth:`PeriodIndex.shift`, use "periods" instead (:issue:`22458`)
446450
- Changed the default value for the `raw` argument in :func:`Series.rolling().apply() <pandas.core.window.Rolling.apply>`, :func:`DataFrame.rolling().apply() <pandas.core.window.Rolling.apply>`,
447451
- :func:`Series.expanding().apply() <pandas.core.window.Expanding.apply>`, and :func:`DataFrame.expanding().apply() <pandas.core.window.Expanding.apply>` to ``False`` (:issue:`20584`)
452+
- Removed previously deprecated :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` (:issue:`18164`)
448453
-
449454

450455
.. _whatsnew_1000.performance:
@@ -526,7 +531,8 @@ Numeric
526531
- Improved error message when using `frac` > 1 and `replace` = False (:issue:`27451`)
527532
- Bug in numeric indexes resulted in it being possible to instantiate an :class:`Int64Index`, :class:`UInt64Index`, or :class:`Float64Index` with an invalid dtype (e.g. datetime-like) (:issue:`29539`)
528533
- Bug in :class:`UInt64Index` precision loss while constructing from a list with values in the ``np.uint64`` range (:issue:`29526`)
529-
-
534+
- Bug in :class:`NumericIndex` construction that caused indexing to fail when integers in the ``np.uint64`` range were used (:issue:`28023`)
535+
- Bug in :class:`NumericIndex` construction that caused :class:`UInt64Index` to be casted to :class:`Float64Index` when integers in the ``np.uint64`` range were used to index a :class:`DataFrame` (:issue:`28279`)
530536

531537
Conversion
532538
^^^^^^^^^^

pandas/_libs/internals.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cdef class BlockPlacement:
5454
else:
5555
v = self._as_array
5656

57-
return f'{self.__class__.__name__}({v})'
57+
return f'{type(self).__name__}({v})'
5858

5959
def __repr__(self) -> str:
6060
return str(self)

pandas/_libs/lib.pyx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from fractions import Fraction
44
from numbers import Number
55

66
import sys
7-
import warnings
87

98
import cython
109
from cython import Py_ssize_t
@@ -615,7 +614,7 @@ def clean_index_list(obj: list):
615614

616615
# don't force numpy coerce with nan's
617616
inferred = infer_dtype(obj, skipna=False)
618-
if inferred in ['string', 'bytes', 'unicode', 'mixed', 'mixed-integer']:
617+
if inferred in ['string', 'bytes', 'mixed', 'mixed-integer']:
619618
return np.asarray(obj, dtype=object), 0
620619
elif inferred in ['integer']:
621620
# TODO: we infer an integer but it *could* be a uint64
@@ -1094,15 +1093,15 @@ cdef _try_infer_map(v):
10941093
return None
10951094

10961095

1097-
def infer_dtype(value: object, skipna: object=None) -> str:
1096+
def infer_dtype(value: object, skipna: bool = True) -> str:
10981097
"""
10991098
Efficiently infer the type of a passed val, or list-like
11001099
array of values. Return a string describing the type.
11011100

11021101
Parameters
11031102
----------
11041103
value : scalar, list, ndarray, or pandas type
1105-
skipna : bool, default False
1104+
skipna : bool, default True
11061105
Ignore NaN values when inferring the type.
11071106

11081107
.. versionadded:: 0.21.0
@@ -1113,7 +1112,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
11131112
Results can include:
11141113

11151114
- string
1116-
- unicode
11171115
- bytes
11181116
- floating
11191117
- integer
@@ -1200,12 +1198,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
12001198
bint seen_pdnat = False
12011199
bint seen_val = False
12021200

1203-
if skipna is None:
1204-
msg = ('A future version of pandas will default to `skipna=True`. To '
1205-
'silence this warning, pass `skipna=True|False` explicitly.')
1206-
warnings.warn(msg, FutureWarning, stacklevel=2)
1207-
skipna = False
1208-
12091201
if util.is_array(value):
12101202
values = value
12111203
elif hasattr(value, 'dtype'):

pandas/_libs/tslibs/c_timestamp.pyx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ cdef class _Timestamp(datetime):
8787
return PyObject_RichCompareBool(val, other, op)
8888

8989
try:
90-
ots = self.__class__(other)
90+
ots = type(self)(other)
9191
except ValueError:
9292
return self._compare_outside_nanorange(other, op)
9393
else:
@@ -96,7 +96,7 @@ cdef class _Timestamp(datetime):
9696
if ndim != -1:
9797
if ndim == 0:
9898
if is_datetime64_object(other):
99-
other = self.__class__(other)
99+
other = type(self)(other)
100100
elif is_array(other):
101101
# zero-dim array, occurs if try comparison with
102102
# datetime64 scalar on the left hand side
@@ -105,7 +105,7 @@ cdef class _Timestamp(datetime):
105105
# the numpy C api to extract it.
106106
other = cnp.PyArray_ToScalar(cnp.PyArray_DATA(other),
107107
other)
108-
other = self.__class__(other)
108+
other = type(self)(other)
109109
else:
110110
return NotImplemented
111111
elif is_array(other):
@@ -226,8 +226,7 @@ cdef class _Timestamp(datetime):
226226

227227
if is_timedelta64_object(other):
228228
other_int = other.astype('timedelta64[ns]').view('i8')
229-
return self.__class__(self.value + other_int,
230-
tz=self.tzinfo, freq=self.freq)
229+
return type(self)(self.value + other_int, tz=self.tzinfo, freq=self.freq)
231230

232231
elif is_integer_object(other):
233232
maybe_integer_op_deprecated(self)
@@ -238,8 +237,7 @@ cdef class _Timestamp(datetime):
238237
elif self.freq is None:
239238
raise NullFrequencyError(
240239
"Cannot add integral value to Timestamp without freq.")
241-
return self.__class__((self.freq * other).apply(self),
242-
freq=self.freq)
240+
return type(self)((self.freq * other).apply(self), freq=self.freq)
243241

244242
elif PyDelta_Check(other) or hasattr(other, 'delta'):
245243
# delta --> offsets.Tick
@@ -253,8 +251,7 @@ cdef class _Timestamp(datetime):
253251
other.seconds * 1000000 +
254252
other.microseconds) * 1000
255253

256-
result = self.__class__(self.value + nanos,
257-
tz=self.tzinfo, freq=self.freq)
254+
result = type(self)(self.value + nanos, tz=self.tzinfo, freq=self.freq)
258255
return result
259256

260257
elif is_array(other):
@@ -272,7 +269,7 @@ cdef class _Timestamp(datetime):
272269

273270
result = datetime.__add__(self, other)
274271
if PyDateTime_Check(result):
275-
result = self.__class__(result)
272+
result = type(self)(result)
276273
result.nanosecond = self.nanosecond
277274
return result
278275

@@ -304,9 +301,9 @@ cdef class _Timestamp(datetime):
304301
if (PyDateTime_Check(self)
305302
and (PyDateTime_Check(other) or is_datetime64_object(other))):
306303
if isinstance(self, _Timestamp):
307-
other = self.__class__(other)
304+
other = type(self)(other)
308305
else:
309-
self = other.__class__(self)
306+
self = type(other)(self)
310307

311308
# validate tz's
312309
if not tz_compare(self.tzinfo, other.tzinfo):

pandas/_libs/tslibs/fields.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def build_field_sarray(const int64_t[:] dtindex):
9090
def get_date_name_field(const int64_t[:] dtindex, object field, object locale=None):
9191
"""
9292
Given a int64-based datetime index, return array of strings of date
93-
name based on requested field (e.g. weekday_name)
93+
name based on requested field (e.g. day_name)
9494
"""
9595
cdef:
9696
Py_ssize_t i, count = len(dtindex)
@@ -100,7 +100,7 @@ def get_date_name_field(const int64_t[:] dtindex, object field, object locale=No
100100

101101
out = np.empty(count, dtype=object)
102102

103-
if field == 'day_name' or field == 'weekday_name':
103+
if field == 'day_name':
104104
if locale is None:
105105
names = np.array(DAYS_FULL, dtype=np.object_)
106106
else:

pandas/_libs/tslibs/nattype.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ class NaTType(_NaT):
364364
days_in_month = property(fget=lambda self: np.nan)
365365
daysinmonth = property(fget=lambda self: np.nan)
366366
dayofweek = property(fget=lambda self: np.nan)
367-
weekday_name = property(fget=lambda self: np.nan)
368367

369368
# inject Timedelta properties
370369
days = property(fget=lambda self: np.nan)

0 commit comments

Comments
 (0)