Skip to content

Commit 7525271

Browse files
committed
Merge branch 'master' into fix-skip-error
* master: DOC: Update link and description of the Spyder IDE in Ecosystem docs (pandas-dev#22136) BUG: resample with TimedeltaIndex, fenceposts are off (pandas-dev#22488) Use dispatch_to_series where possible (pandas-dev#22572) BLD: Fix openpyxl to 2.5.5 (pandas-dev#22601)
2 parents 80db0b2 + e2e1a10 commit 7525271

17 files changed

+69
-51
lines changed

ci/appveyor-27.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- matplotlib
1414
- numexpr
1515
- numpy=1.12*
16-
- openpyxl
16+
- openpyxl=2.5.5
1717
- pytables
1818
- python=2.7.*
1919
- pytz

ci/appveyor-36.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- matplotlib
1111
- numexpr
1212
- numpy=1.14*
13-
- openpyxl
13+
- openpyxl=2.5.5
1414
- pyarrow
1515
- pytables
1616
- python-dateutil

ci/circle-27-compat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- jinja2=2.8
99
- numexpr=2.4.4 # we test that we correctly don't use an unsupported numexpr
1010
- numpy=1.9.3
11-
- openpyxl
11+
- openpyxl=2.5.5
1212
- psycopg2
1313
- pytables=3.2.2
1414
- python-dateutil=2.5.0

ci/circle-36-locale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- nomkl
1414
- numexpr
1515
- numpy
16-
- openpyxl
16+
- openpyxl=2.5.5
1717
- psycopg2
1818
- pymysql
1919
- pytables

ci/circle-36-locale_slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- nomkl
1515
- numexpr
1616
- numpy
17-
- openpyxl
17+
- openpyxl=2.5.5
1818
- psycopg2
1919
- pymysql
2020
- pytables

ci/requirements-optional-conda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lxml
1212
matplotlib
1313
nbsphinx
1414
numexpr
15-
openpyxl
15+
openpyxl=2.5.5
1616
pyarrow
1717
pymysql
1818
pytables

ci/requirements-optional-pip.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ lxml
1414
matplotlib
1515
nbsphinx
1616
numexpr
17-
openpyxl
17+
openpyxl=2.5.5
1818
pyarrow
1919
pymysql
2020
tables
@@ -28,4 +28,4 @@ statsmodels
2828
xarray
2929
xlrd
3030
xlsxwriter
31-
xlwt
31+
xlwt

ci/travis-35-osx.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- nomkl
1313
- numexpr
1414
- numpy=1.10.4
15-
- openpyxl
15+
- openpyxl=2.5.5
1616
- pytables
1717
- python=3.5*
1818
- pytz

ci/travis-36-doc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies:
2222
- notebook
2323
- numexpr
2424
- numpy=1.13*
25-
- openpyxl
25+
- openpyxl=2.5.5
2626
- pandoc
2727
- pyqt
2828
- pytables

ci/travis-36-slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- matplotlib
1111
- numexpr
1212
- numpy
13-
- openpyxl
13+
- openpyxl=2.5.5
1414
- patsy
1515
- psycopg2
1616
- pymysql

ci/travis-36.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
- nomkl
1919
- numexpr
2020
- numpy
21-
- openpyxl
21+
- openpyxl=2.5.5
2222
- psycopg2
2323
- pyarrow
2424
- pymysql

doc/source/ecosystem.rst

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ development to remain focused around it's original requirements.
1414

1515
This is an inexhaustive list of projects that build on pandas in order to provide
1616
tools in the PyData space. For a list of projects that depend on pandas,
17-
see the
17+
see the
1818
`libraries.io usage page for pandas <https://libraries.io/pypi/pandas/usage>`_
1919
or `search pypi for pandas <https://pypi.org/search/?q=pandas>`_.
2020

@@ -44,7 +44,7 @@ ML pipeline.
4444
`Featuretools <https://github.com/featuretools/featuretools/>`__
4545
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4646

47-
Featuretools is a Python library for automated feature engineering built on top of pandas. It excels at transforming temporal and relational datasets into feature matrices for machine learning using reusable feature engineering "primitives". Users can contribute their own primitives in Python and share them with the rest of the community.
47+
Featuretools is a Python library for automated feature engineering built on top of pandas. It excels at transforming temporal and relational datasets into feature matrices for machine learning using reusable feature engineering "primitives". Users can contribute their own primitives in Python and share them with the rest of the community.
4848

4949
.. _ecosystem.visualization:
5050

@@ -149,13 +149,30 @@ for pandas ``display.`` settings.
149149
qgrid is "an interactive grid for sorting and filtering
150150
DataFrames in IPython Notebook" built with SlickGrid.
151151

152-
`Spyder <https://github.com/spyder-ide/spyder/>`__
153-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152+
`Spyder <https://www.spyder-ide.org/>`__
153+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154+
155+
Spyder is a cross-platform PyQt-based IDE combining the editing, analysis,
156+
debugging and profiling functionality of a software development tool with the
157+
data exploration, interactive execution, deep inspection and rich visualization
158+
capabilities of a scientific environment like MATLAB or Rstudio.
159+
160+
Its `Variable Explorer <https://docs.spyder-ide.org/variableexplorer.html>`__
161+
allows users to view, manipulate and edit pandas ``Index``, ``Series``,
162+
and ``DataFrame`` objects like a "spreadsheet", including copying and modifying
163+
values, sorting, displaying a "heatmap", converting data types and more.
164+
Pandas objects can also be renamed, duplicated, new columns added,
165+
copyed/pasted to/from the clipboard (as TSV), and saved/loaded to/from a file.
166+
Spyder can also import data from a variety of plain text and binary files
167+
or the clipboard into a new pandas DataFrame via a sophisticated import wizard.
168+
169+
Most pandas classes, methods and data attributes can be autocompleted in
170+
Spyder's `Editor <https://docs.spyder-ide.org/editor.html>`__ and
171+
`IPython Console <https://docs.spyder-ide.org/ipythonconsole.html>`__,
172+
and Spyder's `Help pane<https://docs.spyder-ide.org/help.html>`__ can retrieve
173+
and render Numpydoc documentation on pandas objects in rich text with Sphinx
174+
both automatically and on-demand.
154175

155-
Spyder is a cross-platform Qt-based open-source Python IDE with
156-
editing, testing, debugging, and introspection features.
157-
Spyder can now introspect and display Pandas DataFrames and show
158-
both "column wise min/max and global min/max coloring."
159176

160177
.. _ecosystem.api:
161178

@@ -205,12 +222,12 @@ This package requires valid credentials for this API (non free).
205222
pandaSDMX is a library to retrieve and acquire statistical data
206223
and metadata disseminated in
207224
`SDMX <http://www.sdmx.org>`_ 2.1, an ISO-standard
208-
widely used by institutions such as statistics offices, central banks,
209-
and international organisations. pandaSDMX can expose datasets and related
225+
widely used by institutions such as statistics offices, central banks,
226+
and international organisations. pandaSDMX can expose datasets and related
210227
structural metadata including data flows, code-lists,
211228
and data structure definitions as pandas Series
212229
or MultiIndexed DataFrames.
213-
230+
214231
`fredapi <https://github.com/mortada/fredapi>`__
215232
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216233
fredapi is a Python interface to the `Federal Reserve Economic Data (FRED) <http://research.stlouisfed.org/fred2/>`__

doc/source/whatsnew/v0.24.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ Groupby/Resample/Rolling
709709
datetime-like index leading to incorrect results and also segfault. (:issue:`21704`)
710710
- Bug in :meth:`Resampler.apply` when passing postiional arguments to applied func (:issue:`14615`).
711711
- Bug in :meth:`Series.resample` when passing ``numpy.timedelta64`` to `loffset` kwarg (:issue:`7687`).
712+
- Bug in :meth:`Resampler.asfreq` when frequency of ``TimedeltaIndex`` is a subperiod of a new frequency (:issue:`13022`).
712713

713714
Sparse
714715
^^^^^^

pandas/core/frame.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4832,13 +4832,14 @@ def _arith_op(left, right):
48324832
return ops.dispatch_to_series(this, other, _arith_op)
48334833
else:
48344834
result = _arith_op(this.values, other.values)
4835-
4836-
return self._constructor(result, index=new_index, columns=new_columns,
4837-
copy=False)
4835+
return self._constructor(result,
4836+
index=new_index, columns=new_columns,
4837+
copy=False)
48384838

48394839
def _combine_match_index(self, other, func, level=None):
48404840
left, right = self.align(other, join='outer', axis=0, level=level,
48414841
copy=False)
4842+
assert left.index.equals(right.index)
48424843
new_data = func(left.values.T, right.values).T
48434844
return self._constructor(new_data,
48444845
index=left.index, columns=self.columns,
@@ -4847,6 +4848,7 @@ def _combine_match_index(self, other, func, level=None):
48474848
def _combine_match_columns(self, other, func, level=None, try_cast=True):
48484849
left, right = self.align(other, join='outer', axis=1, level=level,
48494850
copy=False)
4851+
assert left.columns.equals(right.index)
48504852

48514853
new_data = left._data.eval(func=func, other=right,
48524854
axes=[left.columns, self.index],
@@ -4855,12 +4857,7 @@ def _combine_match_columns(self, other, func, level=None, try_cast=True):
48554857

48564858
def _combine_const(self, other, func, errors='raise', try_cast=True):
48574859
if lib.is_scalar(other) or np.ndim(other) == 0:
4858-
new_data = {i: func(self.iloc[:, i], other)
4859-
for i, col in enumerate(self.columns)}
4860-
4861-
result = self._constructor(new_data, index=self.index, copy=False)
4862-
result.columns = self.columns
4863-
return result
4860+
return ops.dispatch_to_series(self, other, func)
48644861

48654862
new_data = self._data.eval(func=func, other=other,
48664863
errors=errors,

pandas/core/ops.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,7 @@ def dispatch_to_series(left, right, func):
16381638
"""
16391639
# Note: we use iloc to access columns for compat with cases
16401640
# with non-unique columns.
1641+
right = lib.item_from_zerodim(right)
16411642
if lib.is_scalar(right):
16421643
new_data = {i: func(left.iloc[:, i], right)
16431644
for i in range(len(left.columns))}

pandas/core/resample.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,10 @@ def _downsample(self, how, **kwargs):
963963
return self._wrap_result(result)
964964

965965
def _adjust_binner_for_upsample(self, binner):
966-
""" adjust our binner when upsampling """
966+
"""
967+
Adjust our binner when upsampling.
968+
The range of a new index should not be outside specified range
969+
"""
967970
if self.closed == 'right':
968971
binner = binner[1:]
969972
else:
@@ -1156,17 +1159,11 @@ def _get_binner_for_time(self):
11561159
return self.groupby._get_time_delta_bins(self.ax)
11571160

11581161
def _adjust_binner_for_upsample(self, binner):
1159-
""" adjust our binner when upsampling """
1160-
ax = self.ax
1161-
1162-
if is_subperiod(ax.freq, self.freq):
1163-
# We are actually downsampling
1164-
# but are in the asfreq path
1165-
# GH 12926
1166-
if self.closed == 'right':
1167-
binner = binner[1:]
1168-
else:
1169-
binner = binner[:-1]
1162+
"""
1163+
Adjust our binner when upsampling.
1164+
The range of a new index is allowed to be greater than original range
1165+
so we don't need to change the length of a binner, GH 13022
1166+
"""
11701167
return binner
11711168

11721169

pandas/tests/test_resample.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from pandas.compat import range, lrange, zip, OrderedDict
2727
from pandas.errors import UnsupportedFunctionCall
2828
import pandas.tseries.offsets as offsets
29-
from pandas.tseries.frequencies import to_offset
3029
from pandas.tseries.offsets import Minute, BDay
3130

3231
from pandas.core.groupby.groupby import DataError
@@ -626,12 +625,7 @@ def test_asfreq(self, series_and_frame, freq):
626625
obj = series_and_frame
627626

628627
result = obj.resample(freq).asfreq()
629-
if freq == '2D':
630-
new_index = obj.index.take(np.arange(0, len(obj.index), 2))
631-
new_index.freq = to_offset('2D')
632-
else:
633-
new_index = self.create_index(obj.index[0], obj.index[-1],
634-
freq=freq)
628+
new_index = self.create_index(obj.index[0], obj.index[-1], freq=freq)
635629
expected = obj.reindex(new_index)
636630
assert_almost_equal(result, expected)
637631

@@ -2932,6 +2926,17 @@ def test_resample_with_nat(self):
29322926
freq='1S'))
29332927
assert_frame_equal(result, expected)
29342928

2929+
def test_resample_as_freq_with_subperiod(self):
2930+
# GH 13022
2931+
index = timedelta_range('00:00:00', '00:10:00', freq='5T')
2932+
df = DataFrame(data={'value': [1, 5, 10]}, index=index)
2933+
result = df.resample('2T').asfreq()
2934+
expected_data = {'value': [1, np.nan, np.nan, np.nan, np.nan, 10]}
2935+
expected = DataFrame(data=expected_data,
2936+
index=timedelta_range('00:00:00',
2937+
'00:10:00', freq='2T'))
2938+
tm.assert_frame_equal(result, expected)
2939+
29352940

29362941
class TestResamplerGrouper(object):
29372942

0 commit comments

Comments
 (0)