Skip to content

Commit 06d35ea

Browse files
committed
Merge remote-tracking branch 'upstream/master' into parser-cleanup
2 parents df25106 + 7ee26a8 commit 06d35ea

Some content is hidden

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

74 files changed

+284
-240
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ install:
8686
- ci/submit_cython_cache.sh
8787
- echo "install done"
8888

89+
before_script:
90+
# display server (for clipboard functionality) needs to be started here,
91+
# does not work if done in install:setup_env.sh (GH-26103)
92+
- export DISPLAY=":99.0"
93+
- echo "sh -e /etc/init.d/xvfb start"
94+
- sh -e /etc/init.d/xvfb start
95+
- sleep 3
96+
8997
script:
9098
- echo "script start"
9199
- source activate pandas-dev

ci/azure/windows.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ jobs:
1919
steps:
2020
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
2121
displayName: Add conda to PATH
22-
- script: conda env create --file ci\\deps\\azure-windows-$(CONDA_PY).yaml
22+
- script: conda update -q -n base conda
23+
displayName: Update conda
24+
- script: conda env create -q --file ci\\deps\\azure-windows-$(CONDA_PY).yaml
2325
displayName: Create anaconda environment
2426
- script: |
2527
call activate pandas-dev
28+
call conda list
2629
ci\\incremental\\build.cmd
2730
displayName: 'Build'
2831
- script: |

ci/code_checks.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,6 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
169169
invgrep -r -E --include '*.py' '(unittest(\.| import )mock|mock\.Mock\(\)|mock\.patch)' pandas/tests/
170170
RET=$(($RET + $?)) ; echo $MSG "DONE"
171171

172-
# Check that we use pytest.raises only as a context manager
173-
#
174-
# For any flake8-compliant code, the only way this regex gets
175-
# matched is if there is no "with" statement preceding "pytest.raises"
176-
MSG='Check for pytest.raises as context manager (a line starting with `pytest.raises` is invalid, needs a `with` to precede it)' ; echo $MSG
177-
MSG='TODO: This check is currently skipped because so many files fail this. Please enable when all are corrected (xref gh-24332)' ; echo $MSG
178-
# invgrep -R --include '*.py' -E '[[:space:]] pytest.raises' pandas/tests
179-
# RET=$(($RET + $?)) ; echo $MSG "DONE"
180-
181172
MSG='Check for wrong space after code-block directive and before colon (".. code-block ::" instead of ".. code-block::")' ; echo $MSG
182173
invgrep -R --include="*.rst" ".. code-block ::" doc/source
183174
RET=$(($RET + $?)) ; echo $MSG "DONE"

ci/deps/azure-windows-37.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: pandas-dev
22
channels:
33
- defaults
4+
- conda-forge
45
dependencies:
56
- beautifulsoup4
67
- bottleneck
8+
- gcsfs
79
- html5lib
810
- jinja2
911
- lxml

ci/setup_env.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,10 @@ echo "conda list"
118118
conda list
119119

120120
# Install DB for Linux
121-
export DISPLAY=":99."
122121
if [ ${TRAVIS_OS_NAME} == "linux" ]; then
123122
echo "installing dbs"
124123
mysql -e 'create database pandas_nosetest;'
125124
psql -c 'create database pandas_nosetest;' -U postgres
126-
127-
echo
128-
echo "sh -e /etc/init.d/xvfb start"
129-
sh -e /etc/init.d/xvfb start
130-
sleep 3
131125
else
132126
echo "not using dbs on non-linux"
133127
fi

doc/source/ecosystem.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ provides a familiar ``DataFrame`` interface for out-of-core, parallel and distri
285285

286286
Dask-ML enables parallel and distributed machine learning using Dask alongside existing machine learning libraries like Scikit-Learn, XGBoost, and TensorFlow.
287287

288+
`Koalas <https://koalas.readthedocs.io/en/latest/>`__
289+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290+
291+
Koalas provides a familiar pandas DataFrame interface on top of Apache Spark. It enables users to leverage multi-cores on one machine or a cluster of machines to speed up or scale their DataFrame code.
292+
288293
`Odo <http://odo.pydata.org>`__
289294
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290295

doc/source/user_guide/computation.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ which is equivalent to using weights
865865
866866
The difference between the above two variants arises because we are
867867
dealing with series which have finite history. Consider a series of infinite
868-
history:
868+
history, with ``adjust=True``:
869869

870870
.. math::
871871
@@ -884,10 +884,11 @@ and a ratio of :math:`1 - \alpha` we have
884884
&= \alpha x_t + (1 - \alpha)[x_{t-1} + (1 - \alpha) x_{t-2} + ...]\alpha\\
885885
&= \alpha x_t + (1 - \alpha) y_{t-1}
886886
887-
which shows the equivalence of the above two variants for infinite series.
888-
When ``adjust=True`` we have :math:`y_0 = x_0` and from the last
889-
representation above we have :math:`y_t = \alpha x_t + (1 - \alpha) y_{t-1}`,
890-
therefore there is an assumption that :math:`x_0` is not an ordinary value
887+
which is the same expression as ``adjust=False`` above and therefore
888+
shows the equivalence of the two variants for infinite series.
889+
When ``adjust=False``, we have :math:`y_0 = x_0` and
890+
:math:`y_t = \alpha x_t + (1 - \alpha) y_{t-1}`.
891+
Therefore, there is an assumption that :math:`x_0` is not an ordinary value
891892
but rather an exponentially weighted moment of the infinite series up to that
892893
point.
893894

doc/source/whatsnew/v0.11.0.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,9 @@ Enhancements
238238

239239
- support ``read_hdf/to_hdf`` API similar to ``read_csv/to_csv``
240240

241-
.. ipython:: python
242-
:suppress:
243-
244-
from pandas.compat import lrange
245-
246241
.. ipython:: python
247242
248-
df = pd.DataFrame({'A': lrange(5), 'B': lrange(5)})
243+
df = pd.DataFrame({'A': range(5), 'B': range(5)})
249244
df.to_hdf('store.h5', 'table', append=True)
250245
pd.read_hdf('store.h5', 'table', where=['index > 2'])
251246

doc/source/whatsnew/v0.12.0.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,8 @@ API changes
8383
``iloc`` API to be *purely* positional based.
8484

8585
.. ipython:: python
86-
:suppress:
8786
88-
from pandas.compat import lrange
89-
90-
.. ipython:: python
91-
92-
df = pd.DataFrame(lrange(5), list('ABCDE'), columns=['a'])
87+
df = pd.DataFrame(range(5), index=list('ABCDE'), columns=['a'])
9388
mask = (df.a % 2 == 0)
9489
mask
9590

doc/source/whatsnew/v0.25.0.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ Other API Changes
249249
- Comparing :class:`Timestamp` with unsupported objects now returns :py:obj:`NotImplemented` instead of raising ``TypeError``. This implies that unsupported rich comparisons are delegated to the other object, and are now consistent with Python 3 behavior for ``datetime`` objects (:issue:`24011`)
250250
- Bug in :meth:`DatetimeIndex.snap` which didn't preserving the ``name`` of the input :class:`Index` (:issue:`25575`)
251251
- The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` (:issue:`26089`)
252+
- The ``arg`` argument in :meth:`pandas.core.window._Window.aggregate` has been renamed to ``func`` (:issue:`26372`)
252253

253254
.. _whatsnew_0250.deprecations:
254255

@@ -257,6 +258,8 @@ Deprecations
257258

258259
- Deprecated the ``units=M`` (months) and ``units=Y`` (year) parameters for ``units`` of :func:`pandas.to_timedelta`, :func:`pandas.Timedelta` and :func:`pandas.TimedeltaIndex` (:issue:`16344`)
259260
- The functions :func:`pandas.to_datetime` and :func:`pandas.to_timedelta` have deprecated the ``box`` keyword. Instead, use :meth:`to_numpy` or :meth:`Timestamp.to_datetime64` or :meth:`Timedelta.to_timedelta64`. (:issue:`24416`)
261+
- The :meth:`DataFrame.compound` and :meth:`Series.compound` methods are deprecated and will be removed in a future version.
262+
260263

261264
.. _whatsnew_0250.prior_deprecations:
262265

@@ -317,7 +320,7 @@ Timedelta
317320

318321
- Bug in :func:`TimedeltaIndex.intersection` where for non-monotonic indices in some cases an empty ``Index`` was returned when in fact an intersection existed (:issue:`25913`)
319322
- Bug with comparisons between :class:`Timedelta` and ``NaT`` raising ``TypeError`` (:issue:`26039`)
320-
-
323+
- Bug when adding or subtracting a :class:`BusinessHour` to a :class:`Timestamp` with the resulting time landing in a following or prior day respectively (:issue:`26381`)
321324

322325
Timezones
323326
^^^^^^^^^
@@ -373,7 +376,7 @@ Indexing
373376
- Improved exception message when calling :meth:`DataFrame.iloc` with a list of non-numeric objects (:issue:`25753`).
374377
- Bug in :meth:`DataFrame.loc` and :meth:`Series.loc` where ``KeyError`` was not raised for a ``MultiIndex`` when the key was less than or equal to the number of levels in the :class:`MultiIndex` (:issue:`14885`).
375378
- Bug in which :meth:`DataFrame.append` produced an erroneous warning indicating that a ``KeyError`` will be thrown in the future when the data to be appended contains new columns (:issue:`22252`).
376-
-
379+
- Bug in which :meth:`DataFrame.to_csv` caused a segfault for a reindexed data frame, when the indices were single-level :class:`MultiIndex` (:issue:`26303`).
377380

378381

379382
Missing
@@ -441,6 +444,7 @@ Groupby/Resample/Rolling
441444
- Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`)
442445
- Bug in :meth:`pandas.core.groupby.GroupBy.nth` where NA values in the grouping would return incorrect results (:issue:`26011`)
443446
- Bug in :meth:`pandas.core.groupby.SeriesGroupBy.transform` where transforming an empty group would raise error (:issue:`26208`)
447+
- Bug in :meth:`pandas.core.groupby.GroupBy.agg` where incorrect results are returned for uint64 columns. (:issue:`26310`)
444448

445449

446450
Reshaping

mypy.ini

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,4 @@ ignore_errors=True
1515
ignore_errors=True
1616

1717
[mypy-pandas.core.indexes.timedeltas]
18-
ignore_errors=True
19-
20-
[mypy-pandas.core.indexing]
21-
ignore_errors=True
22-
23-
[mypy-pandas.core.internals.blocks]
24-
ignore_errors=True
25-
26-
[mypy-pandas.core.ops]
27-
ignore_errors=True
28-
29-
[mypy-pandas.core.panel]
30-
ignore_errors=True
31-
32-
[mypy-pandas.core.resample]
33-
ignore_errors=True
34-
35-
[mypy-pandas.core.reshape.merge]
36-
ignore_errors=True
37-
38-
[mypy-pandas.core.reshape.reshape]
39-
ignore_errors=True
40-
41-
[mypy-pandas.core.series]
42-
ignore_errors=True
43-
44-
[mypy-pandas.core.util.hashing]
45-
ignore_errors=True
46-
47-
[mypy-pandas.core.window]
48-
ignore_errors=True
49-
50-
[mypy-pandas.io.pytables]
51-
ignore_errors=True
52-
53-
[mypy-pandas.util._doctools]
54-
ignore_errors=True
55-
56-
[mypy-pandas.util.testing]
57-
ignore_errors=True
18+
ignore_errors=True

pandas/_libs/tslibs/period.pyx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,10 +2208,6 @@ cdef class _Period:
22082208
def now(cls, freq=None):
22092209
return Period(datetime.now(), freq=freq)
22102210

2211-
# HACK IT UP AND YOU BETTER FIX IT SOON
2212-
def __str__(self):
2213-
return self.__unicode__()
2214-
22152211
@property
22162212
def freqstr(self):
22172213
return self.freq.freqstr
@@ -2221,9 +2217,9 @@ cdef class _Period:
22212217
formatted = period_format(self.ordinal, base)
22222218
return "Period('%s', '%s')" % (formatted, self.freqstr)
22232219

2224-
def __unicode__(self):
2220+
def __str__(self):
22252221
"""
2226-
Return a unicode string representation for a particular DataFrame
2222+
Return a string representation for a particular DataFrame
22272223
"""
22282224
base, mult = get_freq_code(self.freq)
22292225
formatted = period_format(self.ordinal, base)

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,9 +2022,9 @@ def _get_repr(self, length=True, na_rep='NaN', footer=True):
20222022
result = formatter.to_string()
20232023
return str(result)
20242024

2025-
def __unicode__(self):
2025+
def __str__(self):
20262026
"""
2027-
Unicode representation.
2027+
String representation.
20282028
"""
20292029
_maxlen = 10
20302030
if len(self._codes) > _maxlen:

pandas/core/arrays/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ def _add_comparison_ops(cls):
18231823
# ----------
18241824
# Formatting
18251825
# -----------
1826-
def __unicode__(self):
1826+
def __str__(self):
18271827
return '{self}\nFill: {fill}\n{index}'.format(
18281828
self=printing.pprint_thing(self),
18291829
fill=printing.pprint_thing(self.fill_value),

pandas/core/base.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,28 @@
3434

3535
class StringMixin:
3636
"""
37-
Implements string methods so long as object defines a `__unicode__` method.
37+
Implements string methods so long as object defines a `__str__` method.
3838
"""
3939
# side note - this could be made into a metaclass if more than one
4040
# object needs
4141

4242
# ----------------------------------------------------------------------
4343
# Formatting
4444

45-
def __unicode__(self):
46-
raise AbstractMethodError(self)
47-
4845
def __str__(self):
4946
"""
5047
Return a string representation for a particular Object
5148
"""
52-
return self.__unicode__()
49+
raise AbstractMethodError(self)
5350

5451
def __bytes__(self):
5552
"""
56-
Return a string representation for a particular object.
53+
Return a bytes representation for a particular object.
5754
"""
5855
from pandas._config import get_option
5956

6057
encoding = get_option("display.encoding")
61-
return self.__unicode__().encode(encoding, 'replace')
58+
return str(self).encode(encoding, 'replace')
6259

6360
def __repr__(self):
6461
"""
@@ -76,7 +73,7 @@ def _constructor(self):
7673
"""class constructor (for this class it's just `__class__`"""
7774
return self.__class__
7875

79-
def __unicode__(self):
76+
def __str__(self):
8077
"""
8178
Return a string representation for a particular object.
8279
"""
@@ -1572,5 +1569,5 @@ def duplicated(self, keep='first'):
15721569
# ----------------------------------------------------------------------
15731570
# abstracts
15741571

1575-
def _update_inplace(self, result, **kwargs):
1572+
def _update_inplace(self, result, verify_is_copy=True, **kwargs):
15761573
raise AbstractMethodError(self)

pandas/core/computation/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def assigner(self):
734734
def __call__(self):
735735
return self.terms(self.env)
736736

737-
def __unicode__(self):
737+
def __str__(self):
738738
return printing.pprint_thing(self.terms)
739739

740740
def __len__(self):

pandas/core/computation/ops.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(self, name, env, side=None, encoding=None):
6767
def local_name(self):
6868
return self.name.replace(_LOCAL_TAG, '')
6969

70-
def __unicode__(self):
70+
def __str__(self):
7171
return pprint_thing(self.name)
7272

7373
def __call__(self, *args, **kwargs):
@@ -166,7 +166,7 @@ def _resolve_name(self):
166166
def name(self):
167167
return self.value
168168

169-
def __unicode__(self):
169+
def __str__(self):
170170
# in python 2 str() of float
171171
# can truncate shorter than repr()
172172
return repr(self.name)
@@ -188,7 +188,7 @@ def __init__(self, op, operands, *args, **kwargs):
188188
def __iter__(self):
189189
return iter(self.operands)
190190

191-
def __unicode__(self):
191+
def __str__(self):
192192
"""Print a generic n-ary operator and its operands using infix
193193
notation"""
194194
# recurse over the operands
@@ -506,7 +506,7 @@ def __call__(self, env):
506506
operand = self.operand(env)
507507
return self.func(operand)
508508

509-
def __unicode__(self):
509+
def __str__(self):
510510
return pprint_thing('{0}({1})'.format(self.op, self.operand))
511511

512512
@property
@@ -531,7 +531,7 @@ def __call__(self, env):
531531
with np.errstate(all='ignore'):
532532
return self.func.func(*operands)
533533

534-
def __unicode__(self):
534+
def __str__(self):
535535
operands = map(str, self.operands)
536536
return pprint_thing('{0}({1})'.format(self.op, ','.join(operands)))
537537

0 commit comments

Comments
 (0)