Skip to content

Commit de9e3ee

Browse files
committed
Merge remote-tracking branch 'upstream/master' into categorical-csv-2
2 parents 1545734 + 0d239d9 commit de9e3ee

Some content is hidden

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

51 files changed

+1242
-978
lines changed

asv_bench/benchmarks/sparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from itertools import repeat
1+
import itertools
22

33
from .pandas_vb_common import *
44
import scipy.sparse
@@ -33,7 +33,7 @@ def time_sparse_from_scipy(self):
3333
SparseDataFrame(scipy.sparse.rand(1000, 1000, 0.005))
3434

3535
def time_sparse_from_dict(self):
36-
SparseDataFrame(dict(zip(range(1000), repeat([0]))))
36+
SparseDataFrame(dict(zip(range(1000), itertools.repeat([0]))))
3737

3838

3939
class sparse_series_from_coo(object):

ci/requirements-3.6_NUMPY_DEV.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
python=3.6*
22
pytz
3-
cython

ci/requirements-3.6_NUMPY_DEV.build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ pip install --pre --upgrade --timeout=60 -f $PRE_WHEELS numpy scipy
1414
# install dateutil from master
1515
pip install -U git+git://github.com/dateutil/dateutil.git
1616

17+
# cython via pip
18+
pip install cython
19+
1720
true

doc/source/10min.rst

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
np.random.seed(123456)
1212
np.set_printoptions(precision=4, suppress=True)
1313
import matplotlib
14-
matplotlib.style.use('ggplot')
14+
# matplotlib.style.use('default')
1515
pd.options.display.max_rows = 15
1616
1717
#### portions of this were borrowed from the
@@ -95,17 +95,7 @@ will be completed:
9595
df2.append df2.combine_first
9696
df2.apply df2.compound
9797
df2.applymap df2.consolidate
98-
df2.as_blocks df2.convert_objects
99-
df2.asfreq df2.copy
100-
df2.as_matrix df2.corr
101-
df2.astype df2.corrwith
102-
df2.at df2.count
103-
df2.at_time df2.cov
104-
df2.axes df2.cummax
105-
df2.B df2.cummin
106-
df2.between_time df2.cumprod
107-
df2.bfill df2.cumsum
108-
df2.blocks df2.D
98+
df2.D
10999

110100
As you can see, the columns ``A``, ``B``, ``C``, and ``D`` are automatically
111101
tab completed. ``E`` is there as well; the rest of the attributes have been

doc/source/computation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
np.set_printoptions(precision=4, suppress=True)
99
import pandas as pd
1010
import matplotlib
11-
matplotlib.style.use('ggplot')
11+
# matplotlib.style.use('default')
1212
import matplotlib.pyplot as plt
1313
plt.close('all')
1414
pd.options.display.max_rows=15

doc/source/cookbook.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
pd.options.display.max_rows=15
2121
2222
import matplotlib
23-
matplotlib.style.use('ggplot')
23+
# matplotlib.style.use('default')
2424
2525
np.set_printoptions(precision=4, suppress=True)
2626

doc/source/dsintro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
pd.options.display.max_rows = 15
1111
1212
import matplotlib
13-
matplotlib.style.use('ggplot')
13+
# matplotlib.style.use('default')
1414
import matplotlib.pyplot as plt
1515
plt.close('all')
1616

doc/source/gotchas.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Frequently Asked Questions (FAQ)
1414
import pandas as pd
1515
pd.options.display.max_rows = 15
1616
import matplotlib
17-
matplotlib.style.use('ggplot')
17+
# matplotlib.style.use('default')
1818
import matplotlib.pyplot as plt
1919
plt.close('all')
2020

doc/source/groupby.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pandas as pd
1111
pd.options.display.max_rows = 15
1212
import matplotlib
13-
matplotlib.style.use('ggplot')
13+
# matplotlib.style.use('default')
1414
import matplotlib.pyplot as plt
1515
plt.close('all')
1616
from collections import OrderedDict

doc/source/missing_data.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pandas as pd
88
pd.options.display.max_rows=15
99
import matplotlib
10-
matplotlib.style.use('ggplot')
10+
# matplotlib.style.use('default')
1111
import matplotlib.pyplot as plt
1212
1313
.. _missing_data:

doc/source/options.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,10 @@ Unicode Formatting
474474
Enabling this option will affect the performance for printing of DataFrame and Series (about 2 times slower).
475475
Use only when it is actually required.
476476

477-
Some East Asian countries use Unicode characters its width is corresponding to 2 alphabets.
478-
If DataFrame or Series contains these characters, default output cannot be aligned properly.
477+
Some East Asian countries use Unicode characters whose width corresponds to two Latin characters.
478+
If a DataFrame or Series contains these characters, the default output mode may not align them properly.
479479

480-
.. note:: Screen captures are attached for each outputs to show the actual results.
480+
.. note:: Screen captures are attached for each output to show the actual results.
481481

482482
.. ipython:: python
483483
@@ -486,8 +486,9 @@ If DataFrame or Series contains these characters, default output cannot be align
486486
487487
.. image:: _static/option_unicode01.png
488488

489-
Enable ``display.unicode.east_asian_width`` allows pandas to check each character's "East Asian Width" property.
490-
These characters can be aligned properly by checking this property, but it takes longer time than standard ``len`` function.
489+
Enabling ``display.unicode.east_asian_width`` allows pandas to check each character's "East Asian Width" property.
490+
These characters can be aligned properly by setting this option to ``True``. However, this will result in longer render
491+
times than the standard ``len`` function.
491492

492493
.. ipython:: python
493494
@@ -496,9 +497,10 @@ These characters can be aligned properly by checking this property, but it takes
496497
497498
.. image:: _static/option_unicode02.png
498499

499-
In addition, Unicode contains characters which width is "Ambiguous". These character's width should be either 1 or 2 depending on terminal setting or encoding. Because this cannot be distinguished from Python, ``display.unicode.ambiguous_as_wide`` option is added to handle this.
500+
In addition, Unicode characters whose width is "Ambiguous" can either be 1 or 2 characters wide depending on the
501+
terminal setting or encoding. The option ``display.unicode.ambiguous_as_wide`` can be used to handle the ambiguity.
500502

501-
By default, "Ambiguous" character's width, "¡" (inverted exclamation) in below example, is regarded as 1.
503+
By default, an "Ambiguous" character's width, such as "¡" (inverted exclamation) in the example below, is taken to be 1.
502504

503505
.. ipython:: python
504506
@@ -507,7 +509,10 @@ By default, "Ambiguous" character's width, "¡" (inverted exclamation) in below
507509
508510
.. image:: _static/option_unicode03.png
509511

510-
Enabling ``display.unicode.ambiguous_as_wide`` lets pandas to figure these character's width as 2. Note that this option will be effective only when ``display.unicode.east_asian_width`` is enabled. Confirm starting position has been changed, but is not aligned properly because the setting is mismatched with this environment.
512+
Enabling ``display.unicode.ambiguous_as_wide`` makes pandas interpret these characters' widths to be 2.
513+
(Note that this option will only be effective when ``display.unicode.east_asian_width`` is enabled.)
514+
515+
However, setting this option incorrectly for your terminal will cause these characters to be aligned incorrectly:
511516

512517
.. ipython:: python
513518

doc/source/visualization.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
np.set_printoptions(precision=4, suppress=True)
1111
pd.options.display.max_rows = 15
1212
import matplotlib
13-
matplotlib.style.use('ggplot')
13+
# matplotlib.style.use('default')
1414
import matplotlib.pyplot as plt
1515
plt.close('all')
1616
@@ -24,13 +24,6 @@ We use the standard convention for referencing the matplotlib API:
2424
2525
import matplotlib.pyplot as plt
2626
27-
The plots in this document are made using matplotlib's ``ggplot`` style (new in version 1.4):
28-
29-
.. code-block:: python
30-
31-
import matplotlib
32-
matplotlib.style.use('ggplot')
33-
3427
We provide the basics in pandas to easily create decent looking plots.
3528
See the :ref:`ecosystem <ecosystem.visualization>` section for visualization
3629
libraries that go beyond the basics documented here.
@@ -134,7 +127,7 @@ For example, a bar plot can be created the following way:
134127
plt.figure();
135128
136129
@savefig bar_plot_ex.png
137-
df.iloc[5].plot(kind='bar'); plt.axhline(0, color='k')
130+
df.iloc[5].plot(kind='bar');
138131
139132
.. versionadded:: 0.17.0
140133

@@ -154,7 +147,7 @@ and :ref:`DataFrame.boxplot() <visualization.box>` methods, which use a separate
154147

155148
Finally, there are several :ref:`plotting functions <visualization.tools>` in ``pandas.plotting``
156149
that take a :class:`Series` or :class:`DataFrame` as an argument. These
157-
include
150+
include:
158151

159152
* :ref:`Scatter Matrix <visualization.scatter_matrix>`
160153
* :ref:`Andrews Curves <visualization.andrews_curves>`
@@ -1049,6 +1042,21 @@ be colored differently.
10491042
Plot Formatting
10501043
---------------
10511044

1045+
Setting the plot style
1046+
~~~~~~~~~~~~~~~~~~~~~~
1047+
1048+
From version 1.5 and up, matplotlib offers a range of preconfigured plotting styles. Setting the
1049+
style can be used to easily give plots the general look that you want.
1050+
Setting the style is as easy as calling ``matplotlib.style.use(my_plot_style)`` before
1051+
creating your plot. For example you could do ``matplotlib.style.use('ggplot')`` for ggplot-style
1052+
plots.
1053+
1054+
You can see the various available style names at ``matplotlib.style.available`` and it's very
1055+
easy to try them out.
1056+
1057+
General plot style arguments
1058+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1059+
10521060
Most plotting methods have a set of keyword arguments that control the
10531061
layout and formatting of the returned plot:
10541062

doc/source/whatsnew/v0.21.0.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,16 @@ Other API Changes
510510
- :class:`Period` is now immutable, and will now raise an ``AttributeError`` when a user tries to assign a new value to the ``ordinal`` or ``freq`` attributes (:issue:`17116`).
511511
- :func:`to_datetime` when passed a tz-aware ``origin=`` kwarg will now raise a more informative ``ValueError`` rather than a ``TypeError`` (:issue:`16842`)
512512
- Renamed non-functional ``index`` to ``index_col`` in :func:`read_stata` to improve API consistency (:issue:`16342`)
513-
513+
- Bug in :func:`DataFrame.drop` caused boolean labels ``False`` and ``True`` to be treated as labels 0 and 1 respectively when dropping indices from a numeric index. This will now raise a ValueError (:issue:`16877`)
514514

515515
.. _whatsnew_0210.deprecations:
516516

517517
Deprecations
518518
~~~~~~~~~~~~
519519
- :func:`read_excel()` has deprecated ``sheetname`` in favor of ``sheet_name`` for consistency with ``.to_excel()`` (:issue:`10559`).
520-
521520
- ``pd.options.html.border`` has been deprecated in favor of ``pd.options.display.html.border`` (:issue:`15793`).
522-
523521
- :func:`SeriesGroupBy.nth` has deprecated ``True`` in favor of ``'all'`` for its kwarg ``dropna`` (:issue:`11038`).
522+
- :func:`DataFrame.as_blocks` is deprecated, as this is exposing the internal implementation (:issue:`17302`)
524523

525524
.. _whatsnew_0210.prior_deprecations:
526525

@@ -676,4 +675,5 @@ PyPy
676675

677676
Other
678677
^^^^^
678+
- Bug where some inplace operators were not being wrapped and produced a copy when invoked (:issue:`12962`)
679679
- Bug in :func:`eval` where the ``inplace`` parameter was being incorrectly handled (:issue:`16732`)

pandas/_libs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# flake8: noqa
23

34
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime

pandas/_libs/src/datetime.pxd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ cdef extern from "datetime/np_datetime.h":
9494
PANDAS_DATETIMEUNIT fr,
9595
pandas_datetimestruct *result) nogil
9696
int days_per_month_table[2][12]
97+
pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS
9798

9899
int dayofweek(int y, int m, int d) nogil
99100
int is_leapyear(int64_t year) nogil
@@ -161,3 +162,17 @@ cdef inline int64_t _date_to_datetime64(object val,
161162
dts.hour = dts.min = dts.sec = dts.us = 0
162163
dts.ps = dts.as = 0
163164
return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
165+
166+
167+
cdef inline bint check_dts_bounds(pandas_datetimestruct *dts):
168+
"""Returns True if an error needs to be raised"""
169+
cdef:
170+
bint error = False
171+
172+
if (dts.year <= 1677 and
173+
cmp_pandas_datetimestruct(dts, &_NS_MIN_DTS) == -1):
174+
error = True
175+
elif (dts.year >= 2262 and
176+
cmp_pandas_datetimestruct(dts, &_NS_MAX_DTS) == 1):
177+
error = True
178+
return error

pandas/_libs/src/datetime/np_datetime.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt
4040
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
4141
#endif
4242

43+
const pandas_datetimestruct _NS_MIN_DTS = {
44+
1677, 9, 21, 0, 12, 43, 145225, 0, 0};
45+
const pandas_datetimestruct _NS_MAX_DTS = {
46+
2262, 4, 11, 23, 47, 16, 854775, 807000, 0};
47+
48+
4349
const int days_per_month_table[2][12] = {
4450
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
4551
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};

pandas/_libs/src/datetime/np_datetime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ typedef struct {
5454
int num;
5555
} pandas_datetime_metadata;
5656

57+
extern const pandas_datetimestruct _NS_MIN_DTS;
58+
extern const pandas_datetimestruct _NS_MAX_DTS;
59+
5760
// stuff pandas needs
5861
// ----------------------------------------------------------------------------
5962

0 commit comments

Comments
 (0)