Skip to content

Commit 1e527da

Browse files
committed
Merge remote-tracking branch 'upstream/master' into numpy-ea
2 parents f737087 + ef1bd69 commit 1e527da

File tree

129 files changed

+5640
-4439
lines changed

Some content is hidden

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

129 files changed

+5640
-4439
lines changed

asv_bench/benchmarks/frame_methods.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def setup(self):
103103
self.df2 = DataFrame(np.random.randn(N * 50, 10))
104104
self.df3 = DataFrame(np.random.randn(N, 5 * N),
105105
columns=['C' + str(c) for c in range(N * 5)])
106+
self.df4 = DataFrame(np.random.randn(N * 1000, 10))
106107

107108
def time_iteritems(self):
108109
# (monitor no-copying behaviour)
@@ -119,10 +120,70 @@ def time_iteritems_indexing(self):
119120
for col in self.df3:
120121
self.df3[col]
121122

123+
def time_itertuples_start(self):
124+
self.df4.itertuples()
125+
126+
def time_itertuples_read_first(self):
127+
next(self.df4.itertuples())
128+
122129
def time_itertuples(self):
123-
for row in self.df2.itertuples():
130+
for row in self.df4.itertuples():
131+
pass
132+
133+
def time_itertuples_to_list(self):
134+
list(self.df4.itertuples())
135+
136+
def mem_itertuples_start(self):
137+
return self.df4.itertuples()
138+
139+
def peakmem_itertuples_start(self):
140+
self.df4.itertuples()
141+
142+
def mem_itertuples_read_first(self):
143+
return next(self.df4.itertuples())
144+
145+
def peakmem_itertuples(self):
146+
for row in self.df4.itertuples():
147+
pass
148+
149+
def mem_itertuples_to_list(self):
150+
return list(self.df4.itertuples())
151+
152+
def peakmem_itertuples_to_list(self):
153+
list(self.df4.itertuples())
154+
155+
def time_itertuples_raw_start(self):
156+
self.df4.itertuples(index=False, name=None)
157+
158+
def time_itertuples_raw_read_first(self):
159+
next(self.df4.itertuples(index=False, name=None))
160+
161+
def time_itertuples_raw_tuples(self):
162+
for row in self.df4.itertuples(index=False, name=None):
124163
pass
125164

165+
def time_itertuples_raw_tuples_to_list(self):
166+
list(self.df4.itertuples(index=False, name=None))
167+
168+
def mem_itertuples_raw_start(self):
169+
return self.df4.itertuples(index=False, name=None)
170+
171+
def peakmem_itertuples_raw_start(self):
172+
self.df4.itertuples(index=False, name=None)
173+
174+
def peakmem_itertuples_raw_read_first(self):
175+
next(self.df4.itertuples(index=False, name=None))
176+
177+
def peakmem_itertuples_raw(self):
178+
for row in self.df4.itertuples(index=False, name=None):
179+
pass
180+
181+
def mem_itertuples_raw_to_list(self):
182+
return list(self.df4.itertuples(index=False, name=None))
183+
184+
def peakmem_itertuples_raw_to_list(self):
185+
list(self.df4.itertuples(index=False, name=None))
186+
126187
def time_iterrows(self):
127188
for row in self.df.iterrows():
128189
pass

asv_bench/benchmarks/join_merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def setup(self, axis):
5050
self.empty_right = [df, DataFrame()]
5151

5252
def time_concat_series(self, axis):
53-
concat(self.series, axis=axis)
53+
concat(self.series, axis=axis, sort=False)
5454

5555
def time_concat_small_frames(self, axis):
5656
concat(self.small_frames, axis=axis)

asv_bench/benchmarks/panel_ctor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import warnings
22
from datetime import datetime, timedelta
33

4-
from pandas import DataFrame, Panel, DatetimeIndex, date_range
4+
from pandas import DataFrame, Panel, date_range
55

66

77
class DifferentIndexes(object):
@@ -23,9 +23,9 @@ def time_from_dict(self):
2323
class SameIndexes(object):
2424

2525
def setup(self):
26-
idx = DatetimeIndex(start=datetime(1990, 1, 1),
27-
end=datetime(2012, 1, 1),
28-
freq='D')
26+
idx = date_range(start=datetime(1990, 1, 1),
27+
end=datetime(2012, 1, 1),
28+
freq='D')
2929
df = DataFrame({'a': 0, 'b': 1, 'c': 2}, index=idx)
3030
self.data_frames = dict(enumerate([df] * 100))
3131

@@ -40,10 +40,10 @@ def setup(self):
4040
start = datetime(1990, 1, 1)
4141
end = datetime(2012, 1, 1)
4242
df1 = DataFrame({'a': 0, 'b': 1, 'c': 2},
43-
index=DatetimeIndex(start=start, end=end, freq='D'))
43+
index=date_range(start=start, end=end, freq='D'))
4444
end += timedelta(days=1)
4545
df2 = DataFrame({'a': 0, 'b': 1, 'c': 2},
46-
index=DatetimeIndex(start=start, end=end, freq='D'))
46+
index=date_range(start=start, end=end, freq='D'))
4747
dfs = [df1] * 50 + [df2] * 50
4848
self.data_frames = dict(enumerate(dfs))
4949

asv_bench/benchmarks/reindex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import numpy as np
22
import pandas.util.testing as tm
3-
from pandas import (DataFrame, Series, DatetimeIndex, MultiIndex, Index,
3+
from pandas import (DataFrame, Series, MultiIndex, Index,
44
date_range)
55
from .pandas_vb_common import lib
66

77

88
class Reindex(object):
99

1010
def setup(self):
11-
rng = DatetimeIndex(start='1/1/1970', periods=10000, freq='1min')
11+
rng = date_range(start='1/1/1970', periods=10000, freq='1min')
1212
self.df = DataFrame(np.random.rand(10000, 10), index=rng,
1313
columns=range(10))
1414
self.df['foo'] = 'bar'

asv_bench/benchmarks/timedelta.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import datetime
22

33
import numpy as np
4-
from pandas import Series, timedelta_range, to_timedelta, Timestamp, \
5-
Timedelta, TimedeltaIndex, DataFrame
4+
5+
from pandas import (
6+
DataFrame, Series, Timedelta, Timestamp, timedelta_range, to_timedelta)
67

78

89
class TimedeltaConstructor(object):
@@ -122,8 +123,8 @@ def time_timedelta_nanoseconds(self, series):
122123
class TimedeltaIndexing(object):
123124

124125
def setup(self):
125-
self.index = TimedeltaIndex(start='1985', periods=1000, freq='D')
126-
self.index2 = TimedeltaIndex(start='1986', periods=1000, freq='D')
126+
self.index = timedelta_range(start='1985', periods=1000, freq='D')
127+
self.index2 = timedelta_range(start='1986', periods=1000, freq='D')
127128
self.series = Series(range(1000), index=self.index)
128129
self.timedelta = self.index[500]
129130

asv_bench/benchmarks/timestamp.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import datetime
22

3-
from pandas import Timestamp
4-
import pytz
53
import dateutil
4+
import pytz
5+
6+
from pandas import Timestamp
67

78

89
class TimestampConstruction(object):
@@ -46,7 +47,7 @@ def time_dayofweek(self, tz, freq):
4647
self.ts.dayofweek
4748

4849
def time_weekday_name(self, tz, freq):
49-
self.ts.weekday_name
50+
self.ts.day_name
5051

5152
def time_dayofyear(self, tz, freq):
5253
self.ts.dayofyear

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
ci/incremental/install_miniconda.sh
4444
ci/incremental/setup_conda_environment.sh
4545
displayName: 'Set up environment'
46+
condition: true
4647
4748
# Do not require pandas
4849
- script: |

ci/code_checks.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
145145
RET=$(($RET + $?)) ; echo $MSG "DONE"
146146

147147
MSG='Check that the deprecated `assert_raises_regex` is not used (`pytest.raises(match=pattern)` should be used instead)' ; echo $MSG
148-
invgrep -R --exclude=*.pyc --exclude=testing.py --exclude=test_testing.py assert_raises_regex pandas
148+
invgrep -R --exclude=*.pyc --exclude=testing.py --exclude=test_util.py assert_raises_regex pandas
149149
RET=$(($RET + $?)) ; echo $MSG "DONE"
150150

151151
# Check that we use pytest.raises only as a context manager
@@ -158,7 +158,12 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
158158
# RET=$(($RET + $?)) ; echo $MSG "DONE"
159159

160160
MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG
161-
invgrep --exclude="*.svg" -RI "\s$" *
161+
set -o pipefail
162+
if [[ "$AZURE" == "true" ]]; then
163+
! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
164+
else
165+
! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
166+
fi
162167
RET=$(($RET + $?)) ; echo $MSG "DONE"
163168
fi
164169

doc/source/basics.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,7 @@ To evaluate single-element pandas objects in a boolean context, use the method
397397
398398
>>> df and df2
399399
400-
These will both raise errors, as you are trying to compare multiple values.
401-
402-
.. code-block:: python-traceback
400+
These will both raise errors, as you are trying to compare multiple values.::
403401

404402
ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().
405403

doc/source/io.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.. _io:
22

3+
.. currentmodule:: pandas
4+
5+
36
{{ header }}
47

58
.. ipython:: python

doc/source/tutorials.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ Video Tutorials
8888
`GitHub repo <https://github.com/TomAugspurger/pydata-chi-h2t>`__
8989
* `Data analysis in Python with pandas <https://www.youtube.com/playlist?list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y>`_
9090
(2016-2018)
91-
`GitHub repo <https://github.com/justmarkham/pandas-videos>`_ and
92-
`Jupyter Notebook <http://nbviewer.jupyter.org/github/justmarkham/pandas-videos/blob/master/pandas.ipynb>`_
91+
`GitHub repo <https://github.com/justmarkham/pandas-videos>`__ and
92+
`Jupyter Notebook <http://nbviewer.jupyter.org/github/justmarkham/pandas-videos/blob/master/pandas.ipynb>`__
9393
* `Best practices with pandas <https://www.youtube.com/playlist?list=PL5-da3qGB5IBITZj_dYSFqnd_15JgqwA6>`_
9494
(2018)
95-
`GitHub repo <https://github.com/justmarkham/pycon-2018-tutorial>`_ and
96-
`Jupyter Notebook <http://nbviewer.jupyter.org/github/justmarkham/pycon-2018-tutorial/blob/master/tutorial.ipynb>`_
95+
`GitHub repo <https://github.com/justmarkham/pycon-2018-tutorial>`__ and
96+
`Jupyter Notebook <http://nbviewer.jupyter.org/github/justmarkham/pycon-2018-tutorial/blob/master/tutorial.ipynb>`__
9797

9898

9999
Various Tutorials

doc/source/whatsnew/v0.13.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ Enhancements
690690

691691
.. ipython:: python
692692
693-
ser = Series([1, 3, np.nan, np.nan, np.nan, 11])
693+
ser = pd.Series([1, 3, np.nan, np.nan, np.nan, 11])
694694
ser.interpolate(limit=2)
695695
696696
- Added ``wide_to_long`` panel data convenience function. See :ref:`the docs<reshaping.melt>`.
@@ -706,7 +706,7 @@ Enhancements
706706
})
707707
df["id"] = df.index
708708
df
709-
wide_to_long(df, ["A", "B"], i="id", j="year")
709+
pd.wide_to_long(df, ["A", "B"], i="id", j="year")
710710
711711
.. _scipy: http://www.scipy.org
712712
.. _documentation: http://docs.scipy.org/doc/scipy/reference/interpolate.html#univariate-interpolation

doc/source/whatsnew/v0.13.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Output Formatting Enhancements
8888

8989
Previously output might look like:
9090

91-
.. oode-block:: text
91+
.. code-block:: text
9292
9393
age today diff
9494
0 2001-01-01 00:00:00 2013-04-19 00:00:00 4491 days, 00:00:00

doc/source/whatsnew/v0.14.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Enhancements
122122
pytz timezones across pandas. (:issue:`4688`)
123123

124124
.. ipython:: python
125+
125126
rng = pd.date_range('3/6/2012 00:00', periods=10, freq='D',
126127
tz='dateutil/Europe/London')
127128
rng.tz

doc/source/whatsnew/v0.15.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ Timezone handling improvements
316316
previously this resulted in ``Exception`` or ``TypeError`` (:issue:`7812`)
317317

318318
.. ipython:: python
319+
:okwarning:
319320
320321
ts = Timestamp('2014-08-01 09:00', tz='US/Eastern')
321322
ts

doc/source/whatsnew/v0.20.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ URLs and paths are now inferred using their file extensions. Additionally,
189189
support for bz2 compression in the python 2 C-engine improved (:issue:`14874`).
190190

191191
.. ipython:: python
192+
:okwarning:
192193
193194
url = ('https://github.com/{repo}/raw/{branch}/{path}'
194195
.format(repo='pandas-dev/pandas',

0 commit comments

Comments
 (0)