Skip to content

Commit 0d68e31

Browse files
author
jnecus
committed
Merge remote-tracking branch 'upstream/master'
2 parents 14e2c79 + dede2c7 commit 0d68e31

Some content is hidden

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

77 files changed

+2954
-2609
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ matrix:
7575

7676
before_install:
7777
- echo "before_install"
78-
# set non-blocking IO on travis
79-
# https://github.com/travis-ci/travis-ci/issues/8920#issuecomment-352661024
78+
# Use blocking IO on travis. Ref: https://github.com/travis-ci/travis-ci/issues/8920#issuecomment-352661024
8079
- python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
8180
- source ci/travis_process_gbq_encryption.sh
8281
- export PATH="$HOME/miniconda3/bin:$PATH"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[![Downloads](https://anaconda.org/conda-forge/pandas/badges/downloads.svg)](https://pandas.pydata.org)
1717
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pydata/pandas)
1818
[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org)
19+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1920

2021
## What is it?
2122

doc/source/ecosystem.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ substantial projects that you feel should be on this list, please let us know.
3030
Data cleaning and validation
3131
----------------------------
3232

33-
`pyjanitor <https://github.com/ericmjl/pyjanitor/>`__
33+
`Pyjanitor <https://github.com/ericmjl/pyjanitor/>`__
3434
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3535

3636
Pyjanitor provides a clean API for cleaning data, using method chaining.
@@ -115,7 +115,7 @@ It is very similar to the matplotlib plotting backend, but provides interactive
115115
web-based charts and maps.
116116

117117

118-
`seaborn <https://seaborn.pydata.org>`__
118+
`Seaborn <https://seaborn.pydata.org>`__
119119
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120120

121121
Seaborn is a Python visualization library based on
@@ -136,7 +136,7 @@ provides a powerful, declarative and extremely general way to generate bespoke p
136136
Various implementations to other languages are available.
137137
A good implementation for Python users is `has2k1/plotnine <https://github.com/has2k1/plotnine/>`__.
138138

139-
`IPython Vega <https://github.com/vega/ipyvega>`__
139+
`IPython vega <https://github.com/vega/ipyvega>`__
140140
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141141

142142
`IPython Vega <https://github.com/vega/ipyvega>`__ leverages `Vega
@@ -147,7 +147,7 @@ A good implementation for Python users is `has2k1/plotnine <https://github.com/h
147147

148148
`Plotly’s <https://plot.ly/>`__ `Python API <https://plot.ly/python/>`__ enables interactive figures and web shareability. Maps, 2D, 3D, and live-streaming graphs are rendered with WebGL and `D3.js <https://d3js.org/>`__. The library supports plotting directly from a pandas DataFrame and cloud-based collaboration. Users of `matplotlib, ggplot for Python, and Seaborn <https://plot.ly/python/matplotlib-to-plotly-tutorial/>`__ can convert figures into interactive web-based plots. Plots can be drawn in `IPython Notebooks <https://plot.ly/ipython-notebooks/>`__ , edited with R or MATLAB, modified in a GUI, or embedded in apps and dashboards. Plotly is free for unlimited sharing, and has `cloud <https://plot.ly/product/plans/>`__, `offline <https://plot.ly/python/offline/>`__, or `on-premise <https://plot.ly/product/enterprise/>`__ accounts for private use.
149149

150-
`QtPandas <https://github.com/draperjames/qtpandas>`__
150+
`Qtpandas <https://github.com/draperjames/qtpandas>`__
151151
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152152

153153
Spun off from the main pandas library, the `qtpandas <https://github.com/draperjames/qtpandas>`__
@@ -187,7 +187,7 @@ See :ref:`Options and Settings <options>` and
187187
:ref:`Available Options <options.available>`
188188
for pandas ``display.`` settings.
189189

190-
`quantopian/qgrid <https://github.com/quantopian/qgrid>`__
190+
`Quantopian/qgrid <https://github.com/quantopian/qgrid>`__
191191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192192

193193
qgrid is "an interactive grid for sorting and filtering
@@ -249,12 +249,12 @@ The following data feeds are available:
249249
* Stooq Index Data
250250
* MOEX Data
251251

252-
`quandl/Python <https://github.com/quandl/Python>`__
252+
`Quandl/Python <https://github.com/quandl/Python>`__
253253
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
254254
Quandl API for Python wraps the Quandl REST API to return
255255
Pandas DataFrames with timeseries indexes.
256256

257-
`pydatastream <https://github.com/vfilimonov/pydatastream>`__
257+
`Pydatastream <https://github.com/vfilimonov/pydatastream>`__
258258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259259
PyDatastream is a Python interface to the
260260
`Refinitiv Datastream (DWS) <https://www.refinitiv.com/en/products/datastream-macroeconomic-analysis>`__
@@ -384,7 +384,7 @@ Pandas provides an interface for defining
384384
system. The following libraries implement that interface to provide types not
385385
found in NumPy or pandas, which work well with pandas' data containers.
386386

387-
`cyberpandas`_
387+
`Cyberpandas`_
388388
~~~~~~~~~~~~~~
389389

390390
Cyberpandas provides an extension type for storing arrays of IP Addresses. These
@@ -411,4 +411,4 @@ Library Accessor Classes Description
411411
.. _pdvega: https://altair-viz.github.io/pdvega/
412412
.. _Altair: https://altair-viz.github.io/
413413
.. _pandas_path: https://github.com/drivendataorg/pandas-path/
414-
.. _pathlib.Path: https://docs.python.org/3/library/pathlib.html
414+
.. _pathlib.Path: https://docs.python.org/3/library/pathlib.html

doc/source/reference/offset_frequency.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ Properties
10441044
Tick.nanos
10451045
Tick.normalize
10461046
Tick.rule_code
1047+
Tick.n
10471048

10481049
Methods
10491050
~~~~~~~
@@ -1077,6 +1078,7 @@ Properties
10771078
Day.nanos
10781079
Day.normalize
10791080
Day.rule_code
1081+
Day.n
10801082

10811083
Methods
10821084
~~~~~~~
@@ -1110,6 +1112,7 @@ Properties
11101112
Hour.nanos
11111113
Hour.normalize
11121114
Hour.rule_code
1115+
Hour.n
11131116

11141117
Methods
11151118
~~~~~~~
@@ -1143,6 +1146,7 @@ Properties
11431146
Minute.nanos
11441147
Minute.normalize
11451148
Minute.rule_code
1149+
Minute.n
11461150

11471151
Methods
11481152
~~~~~~~
@@ -1176,6 +1180,7 @@ Properties
11761180
Second.nanos
11771181
Second.normalize
11781182
Second.rule_code
1183+
Second.n
11791184

11801185
Methods
11811186
~~~~~~~
@@ -1209,6 +1214,7 @@ Properties
12091214
Milli.nanos
12101215
Milli.normalize
12111216
Milli.rule_code
1217+
Milli.n
12121218

12131219
Methods
12141220
~~~~~~~
@@ -1242,6 +1248,7 @@ Properties
12421248
Micro.nanos
12431249
Micro.normalize
12441250
Micro.rule_code
1251+
Micro.n
12451252

12461253
Methods
12471254
~~~~~~~
@@ -1275,6 +1282,7 @@ Properties
12751282
Nano.nanos
12761283
Nano.normalize
12771284
Nano.rule_code
1285+
Nano.n
12781286

12791287
Methods
12801288
~~~~~~~

doc/source/user_guide/computation.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,24 @@ from present information back to past information. This allows the rolling windo
648648
Currently, this feature is only implemented for time-based windows.
649649
For fixed windows, the closed parameter cannot be set and the rolling window will always have both endpoints closed.
650650

651+
.. _stats.iter_rolling_window:
652+
653+
Iteration over window:
654+
~~~~~~~~~~~~~~~~~~~~~~
655+
656+
.. versionadded:: 1.1.0
657+
658+
``Rolling`` and ``Expanding`` objects now support iteration. Be noted that ``min_periods`` is ignored in iteration.
659+
660+
.. ipython::
661+
662+
In [1]: df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
663+
664+
In [2]: for i in df.rolling(2):
665+
...: print(i)
666+
...:
667+
668+
651669
.. _stats.moments.ts-versus-resampling:
652670

653671
Time-aware rolling vs. resampling

doc/source/whatsnew/v1.1.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ Other enhancements
235235
:class:`~pandas.io.stata.StataWriter`, :class:`~pandas.io.stata.StataWriter117`,
236236
and :class:`~pandas.io.stata.StataWriterUTF8` (:issue:`26599`).
237237
- :meth:`HDFStore.put` now accepts `track_times` parameter. Parameter is passed to ``create_table`` method of ``PyTables`` (:issue:`32682`).
238+
- Make :class:`pandas.core.window.Rolling` and :class:`pandas.core.window.Expanding` iterable(:issue:`11704`)
238239

239240
.. ---------------------------------------------------------------------------
240241
@@ -585,6 +586,7 @@ Deprecations
585586

586587
- :func:`pandas.api.types.is_categorical` is deprecated and will be removed in a future version; use `:func:pandas.api.types.is_categorical_dtype` instead (:issue:`33385`)
587588
- :meth:`Index.get_value` is deprecated and will be removed in a future version (:issue:`19728`)
589+
- :meth:`DateOffset.__call__` is deprecated and will be removed in a future version, use ``offset + other`` instead (:issue:`34171`)
588590

589591
.. ---------------------------------------------------------------------------
590592
@@ -605,6 +607,8 @@ Performance improvements
605607
sparse values from ``scipy.sparse`` matrices using the
606608
:meth:`DataFrame.sparse.from_spmatrix` constructor (:issue:`32821`,
607609
:issue:`32825`, :issue:`32826`, :issue:`32856`, :issue:`32858`).
610+
- Performance improvement for groupby methods :meth:`~pandas.core.groupby.groupby.Groupby.first`
611+
and :meth:`~pandas.core.groupby.groupby.Groupby.last` (:issue:`34178`)
608612
- Performance improvement in :func:`factorize` for nullable (integer and boolean) dtypes (:issue:`33064`).
609613
- Performance improvement in reductions (sum, prod, min, max) for nullable (integer and boolean) dtypes (:issue:`30982`, :issue:`33261`, :issue:`33442`).
610614

@@ -813,6 +817,8 @@ Groupby/resample/rolling
813817
- Bug in :meth:`GroupBy.first` and :meth:`GroupBy.last` where None is not preserved in object dtype (:issue:`32800`)
814818
- Bug in :meth:`Rolling.min` and :meth:`Rolling.max`: Growing memory usage after multiple calls when using a fixed window (:issue:`30726`)
815819
- Bug in :meth:`GroupBy.agg`, :meth:`GroupBy.transform`, and :meth:`GroupBy.resample` where subclasses are not preserved (:issue:`28330`)
820+
- Bug in :meth:`GroupBy.rolling.apply` ignores args and kwargs parameters (:issue:`33433`)
821+
816822

817823
Reshaping
818824
^^^^^^^^^

pandas/_libs/groupby.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ cimport numpy as cnp
99
from numpy cimport (ndarray,
1010
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
1111
uint32_t, uint64_t, float32_t, float64_t, complex64_t, complex128_t)
12+
from numpy.math cimport NAN
1213
cnp.import_array()
1314

14-
cdef extern from "numpy/npy_math.h":
15-
float64_t NAN "NPY_NAN"
16-
1715
from pandas._libs.util cimport numeric, get_nat
1816

1917
from pandas._libs.algos cimport (swap, TiebreakEnumType, TIEBREAK_AVERAGE,

pandas/_libs/hashtable.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ from libc.stdlib cimport malloc, free
88
import numpy as np
99
cimport numpy as cnp
1010
from numpy cimport ndarray, uint8_t, uint32_t, float64_t
11+
from numpy.math cimport NAN
1112
cnp.import_array()
1213

13-
cdef extern from "numpy/npy_math.h":
14-
float64_t NAN "NPY_NAN"
1514

1615
from pandas._libs.khash cimport (
1716
khiter_t,
@@ -54,7 +53,7 @@ from pandas._libs.khash cimport (
5453
)
5554

5655

57-
cimport pandas._libs.util as util
56+
from pandas._libs cimport util
5857

5958
from pandas._libs.missing cimport checknull
6059

pandas/_libs/index.pyx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ from numpy cimport (
1919
cnp.import_array()
2020

2121

22-
cimport pandas._libs.util as util
22+
from pandas._libs cimport util
2323

24-
from pandas._libs.tslibs import Period, Timedelta
2524
from pandas._libs.tslibs.nattype cimport c_NaT as NaT
26-
from pandas._libs.tslibs.base cimport ABCTimestamp
25+
from pandas._libs.tslibs.base cimport ABCTimestamp, ABCTimedelta, ABCPeriod
2726

2827
from pandas._libs.hashtable cimport HashTable
2928

@@ -470,7 +469,7 @@ cdef class TimedeltaEngine(DatetimeEngine):
470469
return 'm8[ns]'
471470

472471
cdef int64_t _unbox_scalar(self, scalar) except? -1:
473-
if not (isinstance(scalar, Timedelta) or scalar is NaT):
472+
if not (isinstance(scalar, ABCTimedelta) or scalar is NaT):
474473
raise TypeError(scalar)
475474
return scalar.value
476475

@@ -480,7 +479,7 @@ cdef class PeriodEngine(Int64Engine):
480479
cdef int64_t _unbox_scalar(self, scalar) except? -1:
481480
if scalar is NaT:
482481
return scalar.value
483-
if isinstance(scalar, Period):
482+
if isinstance(scalar, ABCPeriod):
484483
# NB: we assume that we have the correct freq here.
485484
return scalar.ordinal
486485
raise TypeError(scalar)

pandas/_libs/internals.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import cython
21
from collections import defaultdict
2+
3+
import cython
34
from cython import Py_ssize_t
45

56
from cpython.slice cimport PySlice_GetIndicesEx

pandas/_libs/interval.pyx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ from numpy cimport (
3333
cnp.import_array()
3434

3535

36-
cimport pandas._libs.util as util
36+
from pandas._libs cimport util
3737

3838
from pandas._libs.hashtable cimport Int64Vector
3939
from pandas._libs.tslibs.util cimport (
@@ -42,8 +42,7 @@ from pandas._libs.tslibs.util cimport (
4242
is_timedelta64_object,
4343
)
4444

45-
from pandas._libs.tslibs import Timestamp
46-
from pandas._libs.tslibs.timedeltas import Timedelta
45+
from pandas._libs.tslibs.base cimport ABCTimestamp, ABCTimedelta
4746
from pandas._libs.tslibs.timezones cimport tz_compare
4847

4948

@@ -329,7 +328,7 @@ cdef class Interval(IntervalMixin):
329328
raise ValueError(f"invalid option for 'closed': {closed}")
330329
if not left <= right:
331330
raise ValueError("left side of interval must be <= right side")
332-
if (isinstance(left, Timestamp) and
331+
if (isinstance(left, ABCTimestamp) and
333332
not tz_compare(left.tzinfo, right.tzinfo)):
334333
# GH 18538
335334
raise ValueError("left and right must have the same time zone, got "
@@ -341,7 +340,7 @@ cdef class Interval(IntervalMixin):
341340
def _validate_endpoint(self, endpoint):
342341
# GH 23013
343342
if not (is_integer_object(endpoint) or is_float_object(endpoint) or
344-
isinstance(endpoint, (Timestamp, Timedelta))):
343+
isinstance(endpoint, (ABCTimestamp, ABCTimedelta))):
345344
raise ValueError("Only numeric, Timestamp and Timedelta endpoints "
346345
"are allowed when constructing an Interval.")
347346

@@ -371,7 +370,7 @@ cdef class Interval(IntervalMixin):
371370
right = self.right
372371

373372
# TODO: need more general formatting methodology here
374-
if isinstance(left, Timestamp) and isinstance(right, Timestamp):
373+
if isinstance(left, ABCTimestamp) and isinstance(right, ABCTimestamp):
375374
left = left._short_repr
376375
right = right._short_repr
377376

pandas/_libs/lib.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections import abc
22
from decimal import Decimal
3-
43
import warnings
54

65
import cython
@@ -63,7 +62,7 @@ cdef extern from "numpy/arrayobject.h":
6362
cdef extern from "src/parse_helper.h":
6463
int floatify(object, float64_t *result, int *maybe_int) except -1
6564

66-
cimport pandas._libs.util as util
65+
from pandas._libs cimport util
6766
from pandas._libs.util cimport is_nan, UINT64_MAX, INT64_MAX, INT64_MIN
6867

6968
from pandas._libs.tslib import array_to_datetime

pandas/_libs/missing.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cimport numpy as cnp
88
from numpy cimport ndarray, int64_t, uint8_t, float64_t
99
cnp.import_array()
1010

11-
cimport pandas._libs.util as util
11+
from pandas._libs cimport util
1212

1313

1414
from pandas._libs.tslibs.np_datetime cimport get_datetime64_value, get_timedelta64_value

pandas/_libs/parsers.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cimport numpy as cnp
3434
from numpy cimport ndarray, uint8_t, uint64_t, int64_t, float64_t
3535
cnp.import_array()
3636

37-
cimport pandas._libs.util as util
37+
from pandas._libs cimport util
3838
from pandas._libs.util cimport UINT64_MAX, INT64_MAX, INT64_MIN
3939
import pandas._libs.lib as lib
4040

pandas/_libs/reduction.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from numpy cimport (ndarray,
1414
flatiter)
1515
cnp.import_array()
1616

17-
cimport pandas._libs.util as util
17+
from pandas._libs cimport util
1818
from pandas._libs.lib import maybe_convert_objects, is_scalar
1919

2020

@@ -603,7 +603,7 @@ cdef class BlockSlider:
603603
arr.shape[1] = 0
604604

605605

606-
def compute_reduction(arr: np.ndarray, f, axis: int = 0, dummy=None, labels=None):
606+
def compute_reduction(arr: ndarray, f, axis: int = 0, dummy=None, labels=None):
607607
"""
608608
609609
Parameters

0 commit comments

Comments
 (0)