Skip to content

Commit e721b64

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into bool_ops3
2 parents 9aa41ec + 3b135c3 commit e721b64

Some content is hidden

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

56 files changed

+2041
-1646
lines changed

asv_bench/benchmarks/io/excel.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ def setup(self, engine):
2525
self.writer_read.save()
2626
self.bio_read.seek(0)
2727

28-
self.bio_write = BytesIO()
29-
self.bio_write.seek(0)
30-
self.writer_write = ExcelWriter(self.bio_write, engine=engine)
31-
3228
def time_read_excel(self, engine):
3329
read_excel(self.bio_read)
3430

3531
def time_write_excel(self, engine):
36-
self.df.to_excel(self.writer_write, sheet_name='Sheet1')
37-
self.writer_write.save()
32+
bio_write = BytesIO()
33+
bio_write.seek(0)
34+
writer_write = ExcelWriter(bio_write, engine=engine)
35+
self.df.to_excel(writer_write, sheet_name='Sheet1')
36+
writer_write.save()

doc/source/api.rst

+12-4
Original file line numberDiff line numberDiff line change
@@ -2388,15 +2388,23 @@ Style Export and Import
23882388
Styler.to_excel
23892389

23902390
Plotting
2391-
~~~~~~~~
2391+
--------
23922392

2393-
.. currentmodule:: pandas
2393+
.. currentmodule:: pandas.plotting
2394+
2395+
The following functions are contained in the `pandas.plotting` module.
23942396

23952397
.. autosummary::
23962398
:toctree: generated/
23972399

2398-
plotting.register_matplotlib_converters
2399-
plotting.deregister_matplotlib_converters
2400+
andrews_curves
2401+
bootstrap_plot
2402+
deregister_matplotlib_converters
2403+
lag_plot
2404+
parallel_coordinates
2405+
radviz
2406+
register_matplotlib_converters
2407+
scatter_matrix
24002408

24012409
.. currentmodule:: pandas
24022410

doc/source/install.rst

+15-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Installation
77
============
88

9-
The easiest way for the majority of users to install pandas is to install it
9+
The easiest way to install pandas is to install it
1010
as part of the `Anaconda <http://docs.continuum.io/anaconda/>`__ distribution, a
1111
cross platform distribution for data analysis and scientific computing.
1212
This is the recommended installation method for most users.
@@ -40,7 +40,7 @@ packages that make up the `SciPy <http://www.scipy.org/>`__ stack
4040
(Linux, Mac OS X, Windows) Python distribution for data analytics and
4141
scientific computing.
4242

43-
After running a simple installer, the user will have access to pandas and the
43+
After running the installer, the user will have access to pandas and the
4444
rest of the `SciPy <http://www.scipy.org/>`__ stack without needing to install
4545
anything else, and without needing to wait for any software to be compiled.
4646

@@ -51,9 +51,9 @@ A full list of the packages available as part of the
5151
`Anaconda <http://docs.continuum.io/anaconda/>`__ distribution
5252
`can be found here <http://docs.continuum.io/anaconda/pkg-docs.html>`__.
5353

54-
An additional advantage of installing with Anaconda is that you don't require
55-
admin rights to install it, it will install in the user's home directory, and
56-
this also makes it trivial to delete Anaconda at a later date (just delete
54+
Another advantage to installing Anaconda is that you don't need
55+
admin rights to install it. Anaconda can install in the user's home directory,
56+
which makes it trivial to delete Anaconda if you decide (just delete
5757
that folder).
5858

5959
.. _install.miniconda:
@@ -85,9 +85,9 @@ downloading and running the `Miniconda
8585
will do this for you. The installer
8686
`can be found here <http://conda.pydata.org/miniconda.html>`__
8787

88-
The next step is to create a new conda environment (these are analogous to a
89-
virtualenv but they also allow you to specify precisely which Python version
90-
to install also). Run the following commands from a terminal window::
88+
The next step is to create a new conda environment. A conda environment is like a
89+
virtualenv that allows you to specify a specific version of Python and set of libraries.
90+
Run the following commands from a terminal window::
9191

9292
conda create -n name_of_my_env python
9393

@@ -118,8 +118,8 @@ distribution::
118118

119119
conda install anaconda
120120

121-
If you require any packages that are available to pip but not conda, simply
122-
install pip, and use pip to install these packages::
121+
If you need packages that are available to pip but not conda, then
122+
install pip, and then use pip to install those packages::
123123

124124
conda install pip
125125
pip install django
@@ -134,15 +134,12 @@ pandas can be installed via pip from
134134

135135
pip install pandas
136136

137-
This will likely require the installation of a number of dependencies,
138-
including NumPy, will require a compiler to compile required bits of code,
139-
and can take a few minutes to complete.
140137

141138
Installing using your Linux distribution's package manager.
142139
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143140

144141
The commands in this table will install pandas for Python 3 from your distribution.
145-
To install pandas for Python 2 you may need to use the package ``python-pandas``.
142+
To install pandas for Python 2, you may need to use the ``python-pandas`` package.
146143

147144
.. csv-table::
148145
:header: "Distribution", "Status", "Download / Repository Link", "Install method"
@@ -169,9 +166,9 @@ See the :ref:`contributing documentation <contributing>` for complete instructio
169166
Running the test suite
170167
~~~~~~~~~~~~~~~~~~~~~~
171168

172-
pandas is equipped with an exhaustive set of unit tests covering about 97% of
169+
pandas is equipped with an exhaustive set of unit tests, covering about 97% of
173170
the codebase as of this writing. To run it on your machine to verify that
174-
everything is working (and you have all of the dependencies, soft and hard,
171+
everything is working (and that you have all of the dependencies, soft and hard,
175172
installed), make sure you have `pytest
176173
<http://doc.pytest.org/en/latest/>`__ and run:
177174

@@ -214,8 +211,8 @@ Recommended Dependencies
214211

215212
.. note::
216213

217-
You are highly encouraged to install these libraries, as they provide large speedups, especially
218-
if working with large data sets.
214+
You are highly encouraged to install these libraries, as they provide speed improvements, especially
215+
when working with large data sets.
219216

220217

221218
.. _install.optional_dependencies:

doc/source/io.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,14 @@ usecols : array-like or callable, default ``None``
135135
be positional (i.e. integer indices into the document columns) or strings
136136
that correspond to column names provided either by the user in `names` or
137137
inferred from the document header row(s). For example, a valid array-like
138-
`usecols` parameter would be ``[0, 1, 2]`` or ``['foo', 'bar', 'baz']``.
139-
Element order is ignored, so ``usecols=[0, 1]`` is the same as ``[1, 0]``.
138+
`usecols` parameter would be ``[0, 1, 2]`` or ``['foo', 'bar', 'baz']``.
139+
140+
Element order is ignored, so ``usecols=[0, 1]`` is the same as ``[1, 0]``. To
141+
instantiate a DataFrame from ``data`` with element order preserved use
142+
``pd.read_csv(data, usecols=['foo', 'bar'])[['foo', 'bar']]`` for columns
143+
in ``['foo', 'bar']`` order or
144+
``pd.read_csv(data, usecols=['foo', 'bar'])[['bar', 'foo']]`` for
145+
``['bar', 'foo']`` order.
140146

141147
If callable, the callable function will be evaluated against the column names,
142148
returning names where the callable function evaluates to True:

doc/source/whatsnew/v0.23.0.txt

+27-2
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ Convert to an xarray DataArray
345345

346346
p.to_xarray()
347347

348+
349+
350+
.. _whatsnew_0230.api_breaking.core_common:
351+
352+
pandas.core.common removals
353+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
354+
355+
The following error & warning messages are removed from ``pandas.core.common`` (:issue:`13634`, :issue:`19769`):
356+
357+
- ``PerformanceWarning``
358+
- ``UnsupportedFunctionCall``
359+
- ``UnsortedIndexError``
360+
- ``AbstractMethodError``
361+
362+
These are available from import from ``pandas.errors`` (since 0.19.0).
363+
364+
348365
.. _whatsnew_0230.api_breaking.apply:
349366

350367
Changes to make output of ``DataFrame.apply`` consistent
@@ -556,6 +573,7 @@ Datetimelike API Changes
556573
- Subtracting ``NaT`` from a :class:`Series` with ``dtype='datetime64[ns]'`` returns a ``Series`` with ``dtype='timedelta64[ns]'`` instead of ``dtype='datetime64[ns]'`` (:issue:`18808`)
557574
- Operations between a :class:`Series` with dtype ``dtype='datetime64[ns]'`` and a :class:`PeriodIndex` will correctly raises ``TypeError`` (:issue:`18850`)
558575
- Subtraction of :class:`Series` with timezone-aware ``dtype='datetime64[ns]'`` with mis-matched timezones will raise ``TypeError`` instead of ``ValueError`` (:issue:`18817`)
576+
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
559577

560578
.. _whatsnew_0230.api.other:
561579

@@ -575,7 +593,6 @@ Other API Changes
575593
- :func:`Series.fillna` now raises a ``TypeError`` instead of a ``ValueError`` when passed a list, tuple or DataFrame as a ``value`` (:issue:`18293`)
576594
- :func:`pandas.DataFrame.merge` no longer casts a ``float`` column to ``object`` when merging on ``int`` and ``float`` columns (:issue:`16572`)
577595
- :func:`pandas.merge` now raises a ``ValueError`` when trying to merge on incompatible data types (:issue:`9780`)
578-
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
579596
- The default NA value for :class:`UInt64Index` has changed from 0 to ``NaN``, which impacts methods that mask with NA, such as ``UInt64Index.where()`` (:issue:`18398`)
580597
- Refactored ``setup.py`` to use ``find_packages`` instead of explicitly listing out all subpackages (:issue:`18535`)
581598
- Rearranged the order of keyword arguments in :func:`read_excel()` to align with :func:`read_csv()` (:issue:`16672`)
@@ -590,6 +607,7 @@ Other API Changes
590607
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
591608
- :class:`DateOffset` objects render more simply, e.g. ``<DateOffset: days=1>`` instead of ``<DateOffset: kwds={'days': 1}>`` (:issue:`19403`)
592609
- Boolean operations ``&, |, ^`` between a ``Series`` and an ``Index`` will no longer raise ``TypeError`` (:issue:`19792`)
610+
- ``Categorical.fillna`` now validates its ``value`` and ``method`` keyword arguments. It now raises when both or none are specified, matching the behavior of :meth:`Series.fillna` (:issue:`19682`)
593611

594612
.. _whatsnew_0230.deprecations:
595613

@@ -611,6 +629,7 @@ Deprecations
611629

612630
- The ``broadcast`` parameter of ``.apply()`` is deprecated in favor of ``result_type='broadcast'`` (:issue:`18577`)
613631
- The ``reduce`` parameter of ``.apply()`` is deprecated in favor of ``result_type='reduce'`` (:issue:`18577`)
632+
- The ``order`` parameter of :func:`factorize` is deprecated and will be removed in a future release (:issue:`19727`)
614633

615634
.. _whatsnew_0230.prior_deprecations:
616635

@@ -644,6 +663,7 @@ Removal of prior version deprecations/changes
644663
- The modules ``pandas.tools.hashing`` and ``pandas.util.hashing`` have been removed (:issue:`16223`)
645664
- The top-level functions ``pd.rolling_*``, ``pd.expanding_*`` and ``pd.ewm*`` have been removed (Deprecated since v0.18).
646665
Instead, use the DataFrame/Series methods :attr:`~DataFrame.rolling`, :attr:`~DataFrame.expanding` and :attr:`~DataFrame.ewm` (:issue:`18723`)
666+
- Imports from ``pandas.core.common`` for functions such as ``is_datetime64_dtype`` are now removed. These are located in ``pandas.api.types``. (:issue:`13634`, :issue:`19769`)
647667

648668
.. _whatsnew_0230.performance:
649669

@@ -731,6 +751,8 @@ Datetimelike
731751
- Bug in :class:`Timestamp` and :func:`to_datetime` where a string representing a barely out-of-bounds timestamp would be incorrectly rounded down instead of raising ``OutOfBoundsDatetime`` (:issue:`19382`)
732752
- Bug in :func:`Timestamp.floor` :func:`DatetimeIndex.floor` where time stamps far in the future and past were not rounded correctly (:issue:`19206`)
733753
- Bug in :func:`to_datetime` where passing an out-of-bounds datetime with ``errors='coerce'`` and ``utc=True`` would raise ``OutOfBoundsDatetime`` instead of parsing to ``NaT`` (:issue:`19612`)
754+
- Bug in :class:`DatetimeIndex` and :class:`TimedeltaIndex` addition and subtraction where name of the returned object was not always set consistently. (:issue:`19744`)
755+
-
734756

735757
Timedelta
736758
^^^^^^^^^
@@ -742,8 +764,9 @@ Timedelta
742764
- Bug in :class:`TimedeltaIndex` where division by a ``Series`` would return a ``TimedeltaIndex`` instead of a ``Series`` (:issue:`19042`)
743765
- Bug in :func:`Timedelta.__add__`, :func:`Timedelta.__sub__` where adding or subtracting a ``np.timedelta64`` object would return another ``np.timedelta64`` instead of a ``Timedelta`` (:issue:`19738`)
744766
- Bug in :func:`Timedelta.__floordiv__`, :func:`Timedelta.__rfloordiv__` where operating with a ``Tick`` object would raise a ``TypeError`` instead of returning a numeric value (:issue:`19738`)
767+
- Bug in :func:`Period.asfreq` where periods near ``datetime(1, 1, 1)`` could be converted incorrectly (:issue:`19643`)
745768
- Bug in :func:`Timedelta.total_seconds()` causing precision errors i.e. ``Timedelta('30S').total_seconds()==30.000000000000004`` (:issue:`19458`)
746-
769+
-
747770

748771
Timezones
749772
^^^^^^^^^
@@ -794,6 +817,8 @@ Indexing
794817
- Bug in :class:`IntervalIndex` where empty and purely NA data was constructed inconsistently depending on the construction method (:issue:`18421`)
795818
- Bug in :func:`IntervalIndex.symmetric_difference` where the symmetric difference with a non-``IntervalIndex`` did not raise (:issue:`18475`)
796819
- Bug in :class:`IntervalIndex` where set operations that returned an empty ``IntervalIndex`` had the wrong dtype (:issue:`19101`)
820+
- Bug in :meth:`DataFrame.drop_duplicates` where no ``KeyError`` is raised when passing in columns that don't exist on the ``DataFrame`` (issue:`19726`)
821+
797822

798823
MultiIndex
799824
^^^^^^^^^^

pandas/_libs/src/period_helper.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ PANDAS_INLINE npy_int64 transform_via_day(npy_int64 ordinal,
138138
}
139139

140140
static npy_int64 DtoB_weekday(npy_int64 absdate) {
141-
return (((absdate) / 7) * 5) + (absdate) % 7 - BDAY_OFFSET;
141+
return floordiv(absdate, 7) * 5 + mod_compat(absdate, 7) - BDAY_OFFSET;
142142
}
143143

144144
static npy_int64 DtoB(struct date_info *dinfo,
@@ -245,7 +245,8 @@ static npy_int64 asfreq_UpsampleWithinDay(npy_int64 ordinal,
245245
static npy_int64 asfreq_BtoDT(npy_int64 ordinal, asfreq_info *af_info) {
246246
ordinal += BDAY_OFFSET;
247247
ordinal =
248-
(((ordinal - 1) / 5) * 7 + mod_compat(ordinal - 1, 5) + 1 - ORD_OFFSET);
248+
(floordiv(ordinal - 1, 5) * 7 + mod_compat(ordinal - 1, 5) + 1 -
249+
ORD_OFFSET);
249250

250251
return upsample_daytime(ordinal, af_info);
251252
}

0 commit comments

Comments
 (0)