Skip to content

Commit 08c1b95

Browse files
author
Jiang Yue
committed
Merge branch 'master' of https://github.com/jiangyue12392/pandas into integer-na
2 parents fdcaf6e + 5d10aa4 commit 08c1b95

File tree

159 files changed

+2236
-1744
lines changed

Some content is hidden

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

159 files changed

+2236
-1744
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
sudo: false
21
language: python
32
python: 3.5
43

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.PHONY : develop build clean clean_pyc doc lint-diff black
22

3+
all: develop
4+
35
clean:
46
-python setup.py clean
57

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import pandas as pd
2+
3+
4+
class IndexCache:
5+
number = 1
6+
repeat = (3, 100, 20)
7+
8+
params = [
9+
[
10+
"DatetimeIndex",
11+
"Float64Index",
12+
"IntervalIndex",
13+
"Int64Index",
14+
"MultiIndex",
15+
"PeriodIndex",
16+
"RangeIndex",
17+
"TimedeltaIndex",
18+
"UInt64Index",
19+
]
20+
]
21+
param_names = ["index_type"]
22+
23+
def setup(self, index_type):
24+
N = 10 ** 5
25+
if index_type == "MultiIndex":
26+
self.idx = pd.MultiIndex.from_product(
27+
[pd.date_range("1/1/2000", freq="T", periods=N // 2), ["a", "b"]]
28+
)
29+
elif index_type == "DatetimeIndex":
30+
self.idx = pd.date_range("1/1/2000", freq="T", periods=N)
31+
elif index_type == "Int64Index":
32+
self.idx = pd.Index(range(N))
33+
elif index_type == "PeriodIndex":
34+
self.idx = pd.period_range("1/1/2000", freq="T", periods=N)
35+
elif index_type == "RangeIndex":
36+
self.idx = pd.RangeIndex(start=0, stop=N)
37+
elif index_type == "IntervalIndex":
38+
self.idx = pd.IntervalIndex.from_arrays(range(N), range(1, N + 1))
39+
elif index_type == "TimedeltaIndex":
40+
self.idx = pd.TimedeltaIndex(range(N))
41+
elif index_type == "Float64Index":
42+
self.idx = pd.Float64Index(range(N))
43+
elif index_type == "UInt64Index":
44+
self.idx = pd.UInt64Index(range(N))
45+
else:
46+
raise ValueError
47+
assert len(self.idx) == N
48+
self.idx._cache = {}
49+
50+
def time_values(self, index_type):
51+
self.idx._values
52+
53+
def time_shape(self, index_type):
54+
self.idx.shape
55+
56+
def time_is_monotonic(self, index_type):
57+
self.idx.is_monotonic
58+
59+
def time_is_monotonic_decreasing(self, index_type):
60+
self.idx.is_monotonic_decreasing
61+
62+
def time_is_monotonic_increasing(self, index_type):
63+
self.idx.is_monotonic_increasing
64+
65+
def time_is_unique(self, index_type):
66+
self.idx.is_unique
67+
68+
def time_engine(self, index_type):
69+
self.idx._engine
70+
71+
def time_inferred_type(self, index_type):
72+
self.idx.inferred_type
73+
74+
def time_is_all_dates(self, index_type):
75+
self.idx.is_all_dates

asv_bench/benchmarks/io/parsers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
pass
1111

1212

13-
class DoesStringLookLikeDatetime(object):
13+
class DoesStringLookLikeDatetime:
1414

1515
params = (["2Q2005", "0.0", "10000"],)
1616
param_names = ["value"]
@@ -23,7 +23,7 @@ def time_check_datetimes(self, value):
2323
_does_string_look_like_datetime(obj)
2424

2525

26-
class ConcatDateCols(object):
26+
class ConcatDateCols:
2727

2828
params = ([1234567890, "AAAA"], [1, 2])
2929
param_names = ["value", "dim"]

asv_bench/benchmarks/reshape.py

+13
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,17 @@ def time_qcut_datetime(self, bins):
240240
pd.qcut(self.datetime_series, bins)
241241

242242

243+
class Explode:
244+
param_names = ["n_rows", "max_list_length"]
245+
params = [[100, 1000, 10000], [3, 5, 10]]
246+
247+
def setup(self, n_rows, max_list_length):
248+
249+
data = [np.arange(np.random.randint(max_list_length)) for _ in range(n_rows)]
250+
self.series = pd.Series(data)
251+
252+
def time_explode(self, n_rows, max_list_length):
253+
self.series.explode()
254+
255+
243256
from .pandas_vb_common import setup # noqa: F401

asv_bench/benchmarks/series_methods.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def time_series_datetimeindex_repr(self):
219219
getattr(self.s, "a", None)
220220

221221

222-
class All(object):
222+
class All:
223223

224224
params = [[10 ** 3, 10 ** 6], ["fast", "slow"]]
225225
param_names = ["N", "case"]
@@ -232,7 +232,7 @@ def time_all(self, N, case):
232232
self.s.all()
233233

234234

235-
class Any(object):
235+
class Any:
236236

237237
params = [[10 ** 3, 10 ** 6], ["fast", "slow"]]
238238
param_names = ["N", "case"]
@@ -245,7 +245,7 @@ def time_any(self, N, case):
245245
self.s.any()
246246

247247

248-
class NanOps(object):
248+
class NanOps:
249249

250250
params = [
251251
[

asv_bench/benchmarks/timeseries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def time_format_YYYYMMDD(self):
293293
to_datetime(self.stringsD, format="%Y%m%d")
294294

295295

296-
class ToDatetimeCacheSmallCount(object):
296+
class ToDatetimeCacheSmallCount:
297297

298298
params = ([True, False], [50, 500, 5000, 100000])
299299
param_names = ["cache", "count"]

ci/azure/posix.yml

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ jobs:
3333
PATTERN: "not slow and not network"
3434
LOCALE_OVERRIDE: "it_IT.UTF-8"
3535

36+
py36_32bit:
37+
ENV_FILE: ci/deps/azure-36-32bit.yaml
38+
CONDA_PY: "36"
39+
PATTERN: "not slow and not network"
40+
BITS32: "yes"
41+
3642
py37_locale:
3743
ENV_FILE: ci/deps/azure-37-locale.yaml
3844
CONDA_PY: "37"

ci/code_checks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
156156
RET=$(($RET + $?)) ; echo $MSG "DONE"
157157

158158
MSG='Check for python2 new-style classes and for empty parentheses' ; echo $MSG
159-
invgrep -R --include="*.py" --include="*.pyx" -E "class\s\S*\((object)?\):" pandas scripts
159+
invgrep -R --include="*.py" --include="*.pyx" -E "class\s\S*\((object)?\):" pandas asv_bench/benchmarks scripts
160160
RET=$(($RET + $?)) ; echo $MSG "DONE"
161161

162162
MSG='Check for backticks incorrectly rendering because of missing spaces' ; echo $MSG

ci/deps/azure-36-32bit.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: pandas-dev
2+
channels:
3+
- defaults
4+
- conda-forge
5+
dependencies:
6+
- gcc_linux-32
7+
- gcc_linux-32
8+
- gxx_linux-32
9+
- cython=0.28.2
10+
- numpy=1.14.*
11+
- python-dateutil
12+
- python=3.6.*
13+
- pytz=2017.2
14+
# universal
15+
- pytest>=4.0.2,<5.0.0
16+
- pytest-xdist
17+
- pytest-mock
18+
- pytest-azurepipelines
19+
- hypothesis>=3.58.0
20+
- pip

ci/deps/azure-36-locale.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ dependencies:
77
- bottleneck=1.2.*
88
- cython=0.28.2
99
- lxml
10-
- matplotlib=2.2.2
1110
- numpy=1.14.*
1211
- openpyxl=2.4.8
1312
- python-dateutil

ci/deps/azure-37-numpydev.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ dependencies:
1717
- "--pre"
1818
- "numpy"
1919
- "scipy"
20-
- pytest-azurepipelines
20+
# https://github.com/pandas-dev/pandas/issues/27421
21+
- pytest-azurepipelines<1.0.0

ci/deps/azure-macos-35.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ dependencies:
2929
- pytest-xdist
3030
- pytest-mock
3131
- hypothesis>=3.58.0
32-
- pytest-azurepipelines
32+
# https://github.com/pandas-dev/pandas/issues/27421
33+
- pytest-azurepipelines<1.0.0
34+

ci/deps/travis-36-cov.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dependencies:
1111
- gcsfs
1212
- geopandas
1313
- html5lib
14-
- matplotlib
1514
- moto
1615
- nomkl
1716
- numexpr
@@ -39,8 +38,8 @@ dependencies:
3938
- xlsxwriter
4039
- xlwt
4140
# universal
42-
- pytest>=4.0.2
43-
- pytest-xdist
41+
- pytest>=4.0.2,<5.0.0
42+
- pytest-xdist==1.28.0
4443
- pytest-cov
4544
- pytest-mock
4645
- hypothesis>=3.58.0

ci/deps/travis-36-locale.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies:
3535
- xlwt
3636
# universal
3737
- pytest>=4.0.2
38-
- pytest-xdist
38+
- pytest-xdist>=1.29.0
3939
- pytest-mock
4040
- pip
4141
- pip:

ci/setup_env.sh

+6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ echo
9494
echo "conda env create -q --file=${ENV_FILE}"
9595
time conda env create -q --file="${ENV_FILE}"
9696

97+
98+
if [[ "$BITS32" == "yes" ]]; then
99+
# activate 32-bit compiler
100+
export CONDA_BUILD=1
101+
fi
102+
97103
echo "activate pandas-dev"
98104
source activate pandas-dev
99105

doc/source/development/contributing.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ complex changes to the documentation as well.
288288
Some other important things to know about the docs:
289289

290290
* The *pandas* documentation consists of two parts: the docstrings in the code
291-
itself and the docs in this folder ``pandas/doc/``.
291+
itself and the docs in this folder ``doc/``.
292292

293293
The docstrings provide a clear explanation of the usage of the individual
294294
functions, while the documentation in this folder consists of tutorial-like
@@ -404,11 +404,11 @@ Building the documentation
404404
~~~~~~~~~~~~~~~~~~~~~~~~~~
405405

406406
So how do you build the docs? Navigate to your local
407-
``pandas/doc/`` directory in the console and run::
407+
``doc/`` directory in the console and run::
408408

409409
python make.py html
410410

411-
Then you can find the HTML output in the folder ``pandas/doc/build/html/``.
411+
Then you can find the HTML output in the folder ``doc/build/html/``.
412412

413413
The first time you build the docs, it will take quite a while because it has to run
414414
all the code examples and build all the generated docstring pages. In subsequent
@@ -448,7 +448,7 @@ You can also specify to use multiple cores to speed up the documentation build::
448448
Open the following file in a web browser to see the full documentation you
449449
just built::
450450

451-
pandas/docs/build/html/index.html
451+
doc/build/html/index.html
452452

453453
And you'll have the satisfaction of seeing your new and improved documentation!
454454

doc/source/getting_started/basics.rst

-4
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,6 @@ The :meth:`~DataFrame.rename` method also provides an ``inplace`` named
14221422
parameter that is by default ``False`` and copies the underlying data. Pass
14231423
``inplace=True`` to rename the data in place.
14241424

1425-
.. versionadded:: 0.18.0
1426-
14271425
Finally, :meth:`~Series.rename` also accepts a scalar or list-like
14281426
for altering the ``Series.name`` attribute.
14291427

@@ -2063,8 +2061,6 @@ Convert a subset of columns to a specified type using :meth:`~DataFrame.astype`.
20632061
dft
20642062
dft.dtypes
20652063
2066-
.. versionadded:: 0.19.0
2067-
20682064
Convert certain columns to a specific dtype by passing a dict to :meth:`~DataFrame.astype`.
20692065

20702066
.. ipython:: python

doc/source/getting_started/dsintro.rst

-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ Series can also have a ``name`` attribute:
251251
The Series ``name`` will be assigned automatically in many cases, in particular
252252
when taking 1D slices of DataFrame as you will see below.
253253

254-
.. versionadded:: 0.18.0
255-
256254
You can rename a Series with the :meth:`pandas.Series.rename` method.
257255

258256
.. ipython:: python

doc/source/reference/extensions.rst

+35-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,44 @@ objects.
1818
api.extensions.register_series_accessor
1919
api.extensions.register_index_accessor
2020
api.extensions.ExtensionDtype
21-
api.extensions.ExtensionArray
2221

2322
.. autosummary::
2423
:toctree: api/
2524
:template: autosummary/class_without_autosummary.rst
2625

26+
api.extensions.ExtensionArray
2727
arrays.PandasArray
28+
29+
.. We need this autosummary so that methods and attributes are generated.
30+
.. Separate block, since they aren't classes.
31+
32+
.. autosummary::
33+
:toctree: api/
34+
35+
api.extensions.ExtensionArray._concat_same_type
36+
api.extensions.ExtensionArray._formatter
37+
api.extensions.ExtensionArray._formatting_values
38+
api.extensions.ExtensionArray._from_factorized
39+
api.extensions.ExtensionArray._from_sequence
40+
api.extensions.ExtensionArray._from_sequence_of_strings
41+
api.extensions.ExtensionArray._ndarray_values
42+
api.extensions.ExtensionArray._reduce
43+
api.extensions.ExtensionArray._values_for_argsort
44+
api.extensions.ExtensionArray._values_for_factorize
45+
api.extensions.ExtensionArray.argsort
46+
api.extensions.ExtensionArray.astype
47+
api.extensions.ExtensionArray.copy
48+
api.extensions.ExtensionArray.dropna
49+
api.extensions.ExtensionArray.factorize
50+
api.extensions.ExtensionArray.fillna
51+
api.extensions.ExtensionArray.isna
52+
api.extensions.ExtensionArray.ravel
53+
api.extensions.ExtensionArray.repeat
54+
api.extensions.ExtensionArray.searchsorted
55+
api.extensions.ExtensionArray.shift
56+
api.extensions.ExtensionArray.take
57+
api.extensions.ExtensionArray.unique
58+
api.extensions.ExtensionArray.dtype
59+
api.extensions.ExtensionArray.nbytes
60+
api.extensions.ExtensionArray.ndim
61+
api.extensions.ExtensionArray.shape

doc/source/reference/frame.rst

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ Reshaping, sorting, transposing
239239
DataFrame.unstack
240240
DataFrame.swapaxes
241241
DataFrame.melt
242+
DataFrame.explode
242243
DataFrame.squeeze
243244
DataFrame.to_xarray
244245
DataFrame.T

doc/source/reference/series.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ Reshaping, sorting
245245
Series.sort_index
246246
Series.swaplevel
247247
Series.unstack
248+
Series.explode
248249
Series.searchsorted
249250
Series.ravel
250251
Series.repeat
@@ -590,4 +591,3 @@ Sparse
590591

591592
SparseSeries.to_coo
592593
SparseSeries.from_coo
593-

0 commit comments

Comments
 (0)