Skip to content

Commit 64bacc2

Browse files
committed
Merge remote-tracking branch 'upstream/master' into as_index_false
2 parents e344d44 + 0cb7a1f commit 64bacc2

File tree

5 files changed

+36
-49
lines changed

5 files changed

+36
-49
lines changed

.travis.yml

+1-2
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

+1
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

+9-9
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

pandas/_libs/tslibs/offsets.pyx

+9-3
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,13 @@ cdef class _Tick(ABCTick):
852852
self.normalize = False
853853

854854

855-
class BusinessMixin:
855+
class BusinessMixin(BaseOffset):
856856
"""
857857
Mixin to business types to provide related functions.
858858
"""
859+
def __init__(self, n=1, normalize=False, offset=timedelta(0)):
860+
BaseOffset.__init__(self, n, normalize)
861+
object.__setattr__(self, "_offset", offset)
859862

860863
@property
861864
def offset(self):
@@ -879,7 +882,11 @@ class BusinessMixin:
879882
class BusinessHourMixin(BusinessMixin):
880883
_adjust_dst = False
881884

882-
def __init__(self, start="09:00", end="17:00", offset=timedelta(0)):
885+
def __init__(
886+
self, n=1, normalize=False, start="09:00", end="17:00", offset=timedelta(0)
887+
):
888+
BusinessMixin.__init__(self, n, normalize, offset)
889+
883890
# must be validated here to equality check
884891
if np.ndim(start) == 0:
885892
# i.e. not is_list_like
@@ -923,7 +930,6 @@ class BusinessHourMixin(BusinessMixin):
923930

924931
object.__setattr__(self, "start", start)
925932
object.__setattr__(self, "end", end)
926-
object.__setattr__(self, "_offset", offset)
927933

928934
def _repr_attrs(self) -> str:
929935
out = super()._repr_attrs()

pandas/tseries/offsets.py

+16-35
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@ class BusinessDay(BusinessMixin, SingleConstructorOffset):
320320
_prefix = "B"
321321
_attributes = frozenset(["n", "normalize", "offset"])
322322

323-
def __init__(self, n=1, normalize=False, offset=timedelta(0)):
324-
BaseOffset.__init__(self, n, normalize)
325-
object.__setattr__(self, "_offset", offset)
326-
327323
def _offset_str(self) -> str:
328324
def get_str(td):
329325
off_str = ""
@@ -423,7 +419,15 @@ def is_on_offset(self, dt: datetime) -> bool:
423419
return dt.weekday() < 5
424420

425421

426-
class BusinessHourMixin(liboffsets.BusinessHourMixin):
422+
class BusinessHour(SingleConstructorMixin, liboffsets.BusinessHourMixin):
423+
"""
424+
DateOffset subclass representing possibly n business hours.
425+
"""
426+
427+
_prefix = "BH"
428+
_anchor = 0
429+
_attributes = frozenset(["n", "normalize", "start", "end", "offset"])
430+
427431
@cache_readonly
428432
def next_bday(self):
429433
"""
@@ -683,22 +687,6 @@ def _is_on_offset(self, dt):
683687
return False
684688

685689

686-
class BusinessHour(BusinessHourMixin, SingleConstructorOffset):
687-
"""
688-
DateOffset subclass representing possibly n business hours.
689-
"""
690-
691-
_prefix = "BH"
692-
_anchor = 0
693-
_attributes = frozenset(["n", "normalize", "start", "end", "offset"])
694-
695-
def __init__(
696-
self, n=1, normalize=False, start="09:00", end="17:00", offset=timedelta(0)
697-
):
698-
BaseOffset.__init__(self, n, normalize)
699-
super().__init__(start=start, end=end, offset=offset)
700-
701-
702690
class CustomBusinessDay(CustomMixin, BusinessDay):
703691
"""
704692
DateOffset subclass representing custom business days excluding holidays.
@@ -731,9 +719,7 @@ def __init__(
731719
calendar=None,
732720
offset=timedelta(0),
733721
):
734-
BaseOffset.__init__(self, n, normalize)
735-
object.__setattr__(self, "_offset", offset)
736-
722+
BusinessDay.__init__(self, n, normalize, offset)
737723
CustomMixin.__init__(self, weekmask, holidays, calendar)
738724

739725
@apply_wraps
@@ -776,7 +762,7 @@ def is_on_offset(self, dt: datetime) -> bool:
776762
return np.is_busday(day64, busdaycal=self.calendar)
777763

778764

779-
class CustomBusinessHour(CustomMixin, BusinessHourMixin, SingleConstructorOffset):
765+
class CustomBusinessHour(CustomMixin, BusinessHour):
780766
"""
781767
DateOffset subclass representing possibly n custom business days.
782768
"""
@@ -798,11 +784,8 @@ def __init__(
798784
end="17:00",
799785
offset=timedelta(0),
800786
):
801-
BaseOffset.__init__(self, n, normalize)
802-
object.__setattr__(self, "_offset", offset)
803-
787+
BusinessHour.__init__(self, n, normalize, start=start, end=end, offset=offset)
804788
CustomMixin.__init__(self, weekmask, holidays, calendar)
805-
BusinessHourMixin.__init__(self, start=start, end=end, offset=offset)
806789

807790

808791
# ---------------------------------------------------------------------
@@ -902,9 +885,7 @@ def __init__(
902885
calendar=None,
903886
offset=timedelta(0),
904887
):
905-
BaseOffset.__init__(self, n, normalize)
906-
object.__setattr__(self, "_offset", offset)
907-
888+
BusinessMixin.__init__(self, n, normalize, offset)
908889
CustomMixin.__init__(self, weekmask, holidays, calendar)
909890

910891
@cache_readonly
@@ -984,9 +965,9 @@ def __init__(self, n=1, normalize=False, day_of_month=None):
984965
BaseOffset.__init__(self, n, normalize)
985966

986967
if day_of_month is None:
987-
object.__setattr__(self, "day_of_month", self._default_day_of_month)
988-
else:
989-
object.__setattr__(self, "day_of_month", int(day_of_month))
968+
day_of_month = self._default_day_of_month
969+
970+
object.__setattr__(self, "day_of_month", int(day_of_month))
990971
if not self._min_day_of_month <= self.day_of_month <= 27:
991972
raise ValueError(
992973
"day_of_month must be "

0 commit comments

Comments
 (0)