Skip to content

Commit 07cb502

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into offsets-fixweeks
2 parents a35c10b + 08a66e1 commit 07cb502

Some content is hidden

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

42 files changed

+401
-472
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ matrix:
4949
apt:
5050
packages:
5151
- python-gtk2
52+
# In allow_failures
5253
- dist: trusty
5354
env:
54-
- JOB="3.5_CONDA_BUILD_TEST" TEST_ARGS="--skip-slow --skip-network" CONDA_BUILD_TEST=true COVERAGE=true
55+
- JOB="3.5_CONDA_BUILD_TEST" TEST_ARGS="--skip-slow --skip-network" CONDA_BUILD_TEST=true
5556
- dist: trusty
5657
env:
57-
- JOB="3.6" TEST_ARGS="--skip-slow --skip-network" PANDAS_TESTING_MODE="deprecate" CONDA_FORGE=true
58+
- JOB="3.6" TEST_ARGS="--skip-slow --skip-network" PANDAS_TESTING_MODE="deprecate" CONDA_FORGE=true COVERAGE=true
5859
# In allow_failures
5960
- dist: trusty
6061
env:
@@ -76,6 +77,10 @@ matrix:
7677
env:
7778
- JOB="3.6_DOC" DOC=true
7879
allow_failures:
80+
# TODO(jreback)
81+
- dist: trusty
82+
env:
83+
- JOB="3.5_CONDA_BUILD_TEST" TEST_ARGS="--skip-slow --skip-network" CONDA_BUILD_TEST=true
7984
- dist: trusty
8085
env:
8186
- JOB="2.7_SLOW" SLOW=true

asv_bench/benchmarks/replace.py

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,58 @@
1-
from .pandas_vb_common import *
1+
import numpy as np
2+
import pandas as pd
23

4+
from .pandas_vb_common import setup # noqa
35

4-
class replace_fillna(object):
5-
goal_time = 0.2
6-
7-
def setup(self):
8-
self.N = 1000000
9-
try:
10-
self.rng = date_range('1/1/2000', periods=self.N, freq='min')
11-
except NameError:
12-
self.rng = DatetimeIndex('1/1/2000', periods=self.N, offset=datetools.Minute())
13-
self.date_range = DateRange
14-
self.ts = Series(np.random.randn(self.N), index=self.rng)
156

16-
def time_replace_fillna(self):
17-
self.ts.fillna(0.0, inplace=True)
7+
class FillNa(object):
188

19-
20-
class replace_large_dict(object):
219
goal_time = 0.2
10+
params = [True, False]
11+
param_names = ['inplace']
2212

23-
def setup(self):
24-
self.n = (10 ** 6)
25-
self.start_value = (10 ** 5)
26-
self.to_rep = {i: self.start_value + i for i in range(self.n)}
27-
self.s = Series(np.random.randint(self.n, size=(10 ** 3)))
28-
29-
def time_replace_large_dict(self):
30-
self.s.replace(self.to_rep, inplace=True)
13+
def setup(self, inplace):
14+
N = 10**6
15+
rng = pd.date_range('1/1/2000', periods=N, freq='min')
16+
data = np.random.randn(N)
17+
data[::2] = np.nan
18+
self.ts = pd.Series(data, index=rng)
3119

20+
def time_fillna(self, inplace):
21+
self.ts.fillna(0.0, inplace=inplace)
3222

33-
class replace_convert(object):
34-
goal_time = 0.5
23+
def time_replace(self, inplace):
24+
self.ts.replace(np.nan, 0.0, inplace=inplace)
3525

36-
def setup(self):
37-
self.n = (10 ** 3)
38-
self.to_ts = {i: pd.Timestamp(i) for i in range(self.n)}
39-
self.to_td = {i: pd.Timedelta(i) for i in range(self.n)}
40-
self.s = Series(np.random.randint(self.n, size=(10 ** 3)))
41-
self.df = DataFrame({'A': np.random.randint(self.n, size=(10 ** 3)),
42-
'B': np.random.randint(self.n, size=(10 ** 3))})
4326

44-
def time_replace_series_timestamp(self):
45-
self.s.replace(self.to_ts)
27+
class ReplaceDict(object):
4628

47-
def time_replace_series_timedelta(self):
48-
self.s.replace(self.to_td)
29+
goal_time = 0.2
30+
params = [True, False]
31+
param_names = ['inplace']
4932

50-
def time_replace_frame_timestamp(self):
51-
self.df.replace(self.to_ts)
33+
def setup(self, inplace):
34+
N = 10**5
35+
start_value = 10**5
36+
self.to_rep = dict(enumerate(np.arange(N) + start_value))
37+
self.s = pd.Series(np.random.randint(N, size=10**3))
5238

53-
def time_replace_frame_timedelta(self):
54-
self.df.replace(self.to_td)
39+
def time_replace_series(self, inplace):
40+
self.s.replace(self.to_rep, inplace=inplace)
5541

5642

57-
class replace_replacena(object):
58-
goal_time = 0.2
43+
class Convert(object):
5944

60-
def setup(self):
61-
self.N = 1000000
62-
try:
63-
self.rng = date_range('1/1/2000', periods=self.N, freq='min')
64-
except NameError:
65-
self.rng = DatetimeIndex('1/1/2000', periods=self.N, offset=datetools.Minute())
66-
self.date_range = DateRange
67-
self.ts = Series(np.random.randn(self.N), index=self.rng)
68-
69-
def time_replace_replacena(self):
70-
self.ts.replace(np.nan, 0.0, inplace=True)
45+
goal_time = 0.5
46+
params = (['DataFrame', 'Series'], ['Timestamp', 'Timedelta'])
47+
param_names = ['contructor', 'replace_data']
48+
49+
def setup(self, contructor, replace_data):
50+
N = 10**3
51+
data = {'Series': pd.Series(np.random.randint(N, size=N)),
52+
'DataFrame': pd.DataFrame({'A': np.random.randint(N, size=N),
53+
'B': np.random.randint(N, size=N)})}
54+
self.to_replace = {i: getattr(pd, replace_data) for i in range(N)}
55+
self.data = data[contructor]
56+
57+
def time_replace(self, contructor, replace_data):
58+
self.data.replace(self.to_replace)

ci/install_travis.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ if [ "$CONDA_BUILD_TEST" ]; then
5656
conda install conda-build
5757
fi
5858

59+
# TODO(jreback)
60+
echo
61+
echo "[fix conda version]"
62+
conda install conda=4.3.30
63+
5964
echo
6065
echo "[add channels]"
6166
conda config --remove channels defaults || exit 1
@@ -175,7 +180,7 @@ if [ "$PIP_BUILD_TEST" ]; then
175180
echo "[building release]"
176181
bash scripts/build_dist_for_release.sh
177182
conda uninstall -y cython
178-
time pip install dist/*tar.gz || exit 1
183+
time pip install dist/*tar.gz --quiet || exit 1
179184

180185
elif [ "$CONDA_BUILD_TEST" ]; then
181186

doc/source/io.rst

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ usecols : array-like or callable, default ``None``
131131
be positional (i.e. integer indices into the document columns) or strings
132132
that correspond to column names provided either by the user in `names` or
133133
inferred from the document header row(s). For example, a valid array-like
134-
`usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz'].
134+
`usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz']. Element
135+
order is ignored, so usecols=[0,1] is the same as [1, 0].
135136

136137
If callable, the callable function will be evaluated against the column names,
137138
returning names where the callable function evaluates to True:
@@ -199,21 +200,6 @@ low_memory : boolean, default ``True``
199200
Note that the entire file is read into a single DataFrame regardless,
200201
use the ``chunksize`` or ``iterator`` parameter to return the data in chunks.
201202
(Only valid with C parser)
202-
compact_ints : boolean, default False
203-
.. deprecated:: 0.19.0
204-
205-
Argument moved to ``pd.to_numeric``
206-
207-
If ``compact_ints`` is ``True``, then for any column that is of integer dtype, the
208-
parser will attempt to cast it as the smallest integer ``dtype`` possible, either
209-
signed or unsigned depending on the specification from the ``use_unsigned`` parameter.
210-
use_unsigned : boolean, default False
211-
.. deprecated:: 0.18.2
212-
213-
Argument moved to ``pd.to_numeric``
214-
215-
If integer columns are being compacted (i.e. ``compact_ints=True``), specify whether
216-
the column should be compacted to the smallest signed or unsigned integer dtype.
217203
memory_map : boolean, default False
218204
If a filepath is provided for ``filepath_or_buffer``, map the file object
219205
directly onto memory and access the data directly from there. Using this
@@ -2804,11 +2790,11 @@ to be parsed.
28042790
28052791
If `usecols` is a list of integers, then it is assumed to be the file column
28062792
indices to be parsed.
2807-
28082793
.. code-block:: python
28092794
28102795
read_excel('path_to_file.xls', 'Sheet1', usecols=[0, 2, 3])
28112796
2797+
Element order is ignored, so usecols=[0,1] is the same as [1,0].
28122798

28132799
Parsing Dates
28142800
+++++++++++++

doc/source/whatsnew.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ What's New
1818

1919
These are new features and improvements of note in each release.
2020

21+
.. include:: whatsnew/v0.23.0.txt
22+
2123
.. include:: whatsnew/v0.22.0.txt
2224

2325
.. include:: whatsnew/v0.21.1.txt

doc/source/whatsnew/v0.22.0

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _whatsnew_0220:
2+
3+
v0.22.0
4+
-------
5+
6+
This is a major release from 0.21.1 and includes a number of API changes,
7+
deprecations, new features, enhancements, and performance improvements along
8+
with a large number of bug fixes. We recommend that all users upgrade to this
9+
version.
10+
11+
.. _whatsnew_0220.api_breaking:
12+
13+
Backwards incompatible API changes
14+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/source/whatsnew/v0.22.0.txt renamed to doc/source/whatsnew/v0.23.0

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
.. _whatsnew_0220:
1+
.. _whatsnew_0230:
22

3-
v0.22.0
3+
v0.23.0
44
-------
55

66
This is a major release from 0.21.1 and includes a number of API changes,
77
deprecations, new features, enhancements, and performance improvements along
88
with a large number of bug fixes. We recommend that all users upgrade to this
99
version.
1010

11-
.. _whatsnew_0220.enhancements:
11+
.. _whatsnew_0230.enhancements:
1212

1313
New features
1414
~~~~~~~~~~~~
@@ -32,7 +32,7 @@ The :func:`get_dummies` now accepts a ``dtype`` argument, which specifies a dtyp
3232
pd.get_dummies(df, columns=['c'], dtype=bool).dtypes
3333

3434

35-
.. _whatsnew_0220.enhancements.merge_on_columns_and_levels:
35+
.. _whatsnew_0230.enhancements.merge_on_columns_and_levels:
3636

3737
Merging on a combination of columns and index levels
3838
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -63,7 +63,7 @@ levels <merging.merge_on_columns_and_levels>` documentation section.
6363
left.merge(right, on=['key1', 'key2'])
6464

6565

66-
.. _whatsnew_0220.enhancements.ran_inf:
66+
.. _whatsnew_0230.enhancements.ran_inf:
6767

6868
``.rank()`` handles ``inf`` values when ``NaN`` are present
6969
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -119,7 +119,7 @@ Current Behavior
119119

120120
s.rank(na_option='top')
121121

122-
.. _whatsnew_0220.enhancements.other:
122+
.. _whatsnew_0230.enhancements.other:
123123

124124
Other Enhancements
125125
^^^^^^^^^^^^^^^^^^
@@ -139,13 +139,15 @@ Other Enhancements
139139
- :func:`read_excel()` has gained the ``nrows`` parameter (:issue:`16645`)
140140
- :func:``DataFrame.to_json`` and ``Series.to_json`` now accept an ``index`` argument which allows the user to exclude the index from the JSON output (:issue:`17394`)
141141
- ``IntervalIndex.to_tuples()`` has gained the ``na_tuple`` parameter to control whether NA is returned as a tuple of NA, or NA itself (:issue:`18756`)
142+
- ``Categorical.rename_categories``, ``CategoricalIndex.rename_categories`` and :attr:`Series.cat.rename_categories`
143+
can now take a callable as their argument (:issue:`18862`)
142144

143-
.. _whatsnew_0220.api_breaking:
145+
.. _whatsnew_0230.api_breaking:
144146

145147
Backwards incompatible API changes
146148
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147149

148-
.. _whatsnew_0220.api_breaking.deps:
150+
.. _whatsnew_0230.api_breaking.deps:
149151

150152
Dependencies have increased minimum versions
151153
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -169,7 +171,7 @@ Build Changes
169171
- Building from source now explicity requires ``setuptools`` in ``setup.py`` (:issue:`18113`)
170172
- Updated conda recipe to be in compliance with conda-build 3.0+ (:issue:`18002`)
171173

172-
.. _whatsnew_0220.api:
174+
.. _whatsnew_0230.api:
173175

174176
Other API Changes
175177
^^^^^^^^^^^^^^^^^
@@ -199,7 +201,7 @@ Other API Changes
199201
- :func:`pandas.merge` now raises a ``ValueError`` when trying to merge on incompatible data types (:issue:`9780`)
200202
- :func:`wide_to_long` previously kept numeric-like suffixes as ``object`` dtype. Now they are cast to numeric if possible (:issue:`17627`)
201203

202-
.. _whatsnew_0220.deprecations:
204+
.. _whatsnew_0230.deprecations:
203205

204206
Deprecations
205207
~~~~~~~~~~~~
@@ -213,8 +215,9 @@ Deprecations
213215
retain the previous behavior, use a list instead of a tuple (:issue:`18314`)
214216
- ``Series.valid`` is deprecated. Use :meth:`Series.dropna` instead (:issue:`18800`).
215217
- :func:`read_excel` has deprecated the ``skip_footer`` parameter. Use ``skipfooter`` instead (:issue:`18836`)
218+
- The ``is_copy`` attribute is deprecated and will be removed in a future version (:issue:`18801`).
216219

217-
.. _whatsnew_0220.prior_deprecations:
220+
.. _whatsnew_0230.prior_deprecations:
218221

219222
Removal of prior version deprecations/changes
220223
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -233,8 +236,9 @@ Removal of prior version deprecations/changes
233236
- :func:`read_csv` has dropped the ``skip_footer`` parameter (:issue:`13386`)
234237
- :func:`read_csv` has dropped the ``as_recarray`` parameter (:issue:`13373`)
235238
- :func:`read_csv` has dropped the ``buffer_lines`` parameter (:issue:`13360`)
239+
- :func:`read_csv` has dropped the ``compact_ints`` and ``use_unsigned`` parameters (:issue:`13323`)
236240

237-
.. _whatsnew_0220.performance:
241+
.. _whatsnew_0230.performance:
238242

239243
Performance Improvements
240244
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -252,7 +256,7 @@ Performance Improvements
252256
- Improved performance of ``DatetimeIndex`` and ``Series`` arithmetic operations with Business-Month and Business-Quarter frequencies (:issue:`18489`)
253257
- :func:`Series` / :func:`DataFrame` tab completion limits to 100 values, for better performance. (:issue:`18587`)
254258

255-
.. _whatsnew_0220.docs:
259+
.. _whatsnew_0230.docs:
256260

257261
Documentation Changes
258262
~~~~~~~~~~~~~~~~~~~~~
@@ -261,7 +265,7 @@ Documentation Changes
261265
-
262266
-
263267

264-
.. _whatsnew_0220.bug_fixes:
268+
.. _whatsnew_0230.bug_fixes:
265269

266270
Bug Fixes
267271
~~~~~~~~~
@@ -277,6 +281,7 @@ Conversion
277281
- Fixed a bug where ``FY5253`` date offsets could incorrectly raise an ``AssertionError`` in arithmetic operatons (:issue:`14774`)
278282
- Bug in :meth:`Index.astype` with a categorical dtype where the resultant index is not converted to a :class:`CategoricalIndex` for all types of index (:issue:`18630`)
279283
- Bug in :meth:`Series.astype` and ``Categorical.astype()`` where an existing categorical data does not get updated (:issue:`10696`, :issue:`18593`)
284+
- Bug in :class:`Series` constructor with an int or float list where specifying ``dtype=str``, ``dtype='str'`` or ``dtype='U'`` failed to convert the data elements to strings (:issue:`16605`)
280285

281286

282287
Indexing
@@ -294,6 +299,8 @@ Indexing
294299
- Bug in tz-aware :class:`DatetimeIndex` where addition/subtraction with a :class:`TimedeltaIndex` or array with ``dtype='timedelta64[ns]'`` was incorrect (:issue:`17558`)
295300
- :func:`Index.to_series` now accepts ``index`` and ``name`` kwargs (:issue:`18699`)
296301
- :func:`DatetimeIndex.to_series` now accepts ``index`` and ``name`` kwargs (:issue:`18699`)
302+
- Bug in indexing non-scalar value from ``Series`` having non-unique ``Index`` will return value flattened (:issue:`17610`)
303+
297304

298305
I/O
299306
^^^
@@ -302,13 +309,14 @@ I/O
302309
- Bug in :func:`read_msgpack` with a non existent file is passed in Python 2 (:issue:`15296`)
303310
- Bug in :func:`read_csv` where a ``MultiIndex`` with duplicate columns was not being mangled appropriately (:issue:`18062`)
304311
- Bug in :func:`read_sas` where a file with 0 variables gave an ``AttributeError`` incorrectly. Now it gives an ``EmptyDataError`` (:issue:`18184`)
305-
-
312+
- Bug in :func:`DataFrame.to_latex()` where pairs of braces meant to serve as invisible placeholders were escaped (:issue:`18667`)
306313
-
307314

308315
Plotting
309316
^^^^^^^^
310317

311318
- :func: `DataFrame.plot` now raises a ``ValueError`` when the ``x`` or ``y`` argument is improperly formed (:issue:`18671`)
319+
- Bug in formatting tick labels with ``datetime.time()`` and fractional seconds (:issue:`18478`).
312320
-
313321
-
314322

0 commit comments

Comments
 (0)