Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lint-diff:
git diff upstream/master --name-only -- "*.py" | xargs flake8

black:
black . --exclude '(asv_bench/env|\.egg|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist)'
black . --exclude '(asv_bench/env|\.egg|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|setup.py)'

develop: build
python setup.py develop
Expand Down
2 changes: 1 addition & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
black --version

MSG='Checking black formatting' ; echo $MSG
black . --check --exclude '(asv_bench/env|\.egg|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist)'
black . --check --exclude '(asv_bench/env|\.egg|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|setup.py)'
RET=$(($RET + $?)) ; echo $MSG "DONE"

# `setup.cfg` contains the list of error codes that are being ignored in flake8
Expand Down
17 changes: 17 additions & 0 deletions doc/source/development/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,5 +441,22 @@ This would be more or less equivalent to:
The backend module can then use other visualization tools (Bokeh, Altair,...)
to generate the plots.

Libraries implementing the plotting backend should use `entry points <https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins>`__
to make their backend discoverable to pandas. The key is ``"pandas_plotting_backends"``. For example, pandas
registers the default "matplotlib" backend as follows.

.. code-block:: python

# in setup.py
setup( # noqa: F821
...,
entry_points={
"pandas_plotting_backends": [
"matplotlib = pandas:plotting._matplotlib",
],
},
)


More information on how to implement a third-party plotting backend can be found at
https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/__init__.py#L1.
27 changes: 1 addition & 26 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,10 @@ Instructions for installing from source,
`PyPI <https://pypi.org/project/pandas>`__, `ActivePython <https://www.activestate.com/activepython/downloads>`__, various Linux distributions, or a
`development version <http://github.com/pandas-dev/pandas>`__ are also provided.

.. _install.dropping-27:

Plan for dropping Python 2.7
----------------------------

The Python core team plans to stop supporting Python 2.7 on January 1st, 2020.
In line with `NumPy's plans`_, all pandas releases through December 31, 2018
will support Python 2.

The 0.24.x feature release will be the last release to
support Python 2. The released package will continue to be available on
PyPI and through conda.

Starting **January 1, 2019**, all new feature releases (> 0.24) will be Python 3 only.

If there are people interested in continued support for Python 2.7 past December
31, 2018 (either backporting bug fixes or funding) please reach out to the
maintainers on the issue tracker.

For more information, see the `Python 3 statement`_ and the `Porting to Python 3 guide`_.

.. _NumPy's plans: https://github.com/numpy/numpy/blob/master/doc/neps/nep-0014-dropping-python2.7-proposal.rst#plan-for-dropping-python-27-support
.. _Python 3 statement: http://python3statement.org/
.. _Porting to Python 3 guide: https://docs.python.org/3/howto/pyporting.html

Python version support
----------------------

Officially Python 2.7, 3.5, 3.6, and 3.7.
Officially Python 3.5.3 and above, 3.6, and 3.7.

Installing pandas
-----------------
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Check the :ref:`API Changes <whatsnew_0230.api_breaking>` and :ref:`deprecations
.. warning::

Starting January 1, 2019, pandas feature releases will support Python 3 only.
See :ref:`install.dropping-27` for more.
See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more.

.. contents:: What's new in v0.23.0
:local:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and bug fixes. We recommend that all users upgrade to this version.
.. warning::

Starting January 1, 2019, pandas feature releases will support Python 3 only.
See :ref:`install.dropping-27` for more.
See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more.

.. contents:: What's new in v0.23.1
:local:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and bug fixes. We recommend that all users upgrade to this version.
.. warning::

Starting January 1, 2019, pandas feature releases will support Python 3 only.
See :ref:`install.dropping-27` for more.
See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more.

.. contents:: What's new in v0.23.2
:local:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and bug fixes. We recommend that all users upgrade to this version.
.. warning::

Starting January 1, 2019, pandas feature releases will support Python 3 only.
See :ref:`install.dropping-27` for more.
See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more.

.. contents:: What's new in v0.23.4
:local:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ What's new in 0.24.0 (January 25, 2019)
.. warning::

The 0.24.x series of releases will be the last to support Python 2. Future feature
releases will support Python 3 only. See :ref:`install.dropping-27` for more
releases will support Python 3 only. See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more
details.

{{ header }}
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Whats new in 0.24.1 (February 3, 2019)
.. warning::

The 0.24.x series of releases will be the last to support Python 2. Future feature
releases will support Python 3 only. See :ref:`install.dropping-27` for more.
releases will support Python 3 only. See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more.

{{ header }}

Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Whats new in 0.24.2 (March 12, 2019)
.. warning::

The 0.24.x series of releases will be the last to support Python 2. Future feature
releases will support Python 3 only. See :ref:`install.dropping-27` for more.
releases will support Python 3 only. See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more.

{{ header }}

Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ What's new in 0.25.0 (July 18, 2019)
.. warning::

Starting with the 0.25.x series of releases, pandas only supports Python 3.5.3 and higher.
See :ref:`install.dropping-27` for more details.
See `Dropping Python 2.7 <https://pandas.pydata.org/pandas-docs/version/0.24/install.html#install-dropping-27>`_ for more details.

.. warning::

Expand Down
13 changes: 7 additions & 6 deletions doc/source/whatsnew/v0.25.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@ Timedelta
Timezones
^^^^^^^^^

-
- Bug in :class:`Index` where a numpy object array with a timezone aware :class:`Timestamp` and ``np.nan`` would not return a :class:`DatetimeIndex` (:issue:`27011`)
-
-

Numeric
^^^^^^^
-
- Bug in :meth:`Series.interpolate` when using a timezone aware :class:`DatetimeIndex` (:issue:`27548`)
- Bug when printing negative floating point complex numbers would raise an ``IndexError`` (:issue:`27484`)
-
-

Conversion
^^^^^^^^^^

-
- Improved the warnings for the deprecated methods :meth:`Series.real` and :meth:`Series.imag` (:issue:`27610`)
-
-

Expand Down Expand Up @@ -113,21 +114,21 @@ I/O
Plotting
^^^^^^^^

-
- Added a pandas_plotting_backends entrypoint group for registering plot backends. See :ref:`extending.plotting-backends` for more (:issue:`26747`).
-
-

Groupby/resample/rolling
^^^^^^^^^^^^^^^^^^^^^^^^

-
- Bug in :meth:`pandas.core.groupby.DataFrameGroupBy.transform` where applying a timezone conversion lambda function would drop timezone information (:issue:`27496`)
-
-

Reshaping
^^^^^^^^^

-
- A ``KeyError`` is now raised if ``.unstack()`` is called on a :class:`Series` or :class:`DataFrame` with a flat :class:`Index` passing a name which is not the correct one (:issue:`18303`)
-
-

Expand Down
12 changes: 6 additions & 6 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2601,12 +2601,12 @@ def memory_usage(self, index=True, deep=False):
... for t in dtypes])
>>> df = pd.DataFrame(data)
>>> df.head()
int64 float64 complex128 object bool
0 1 1.0 1.0+0.0j 1 True
1 1 1.0 1.0+0.0j 1 True
2 1 1.0 1.0+0.0j 1 True
3 1 1.0 1.0+0.0j 1 True
4 1 1.0 1.0+0.0j 1 True
int64 float64 complex128 object bool
0 1 1.0 1.000000+0.000000j 1 True
1 1 1.0 1.000000+0.000000j 1 True
2 1 1.0 1.000000+0.000000j 1 True
3 1 1.0 1.000000+0.000000j 1 True
4 1 1.0 1.000000+0.000000j 1 True

>>> df.memory_usage()
Index 128
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
is_bool,
is_bool_dtype,
is_datetime64_any_dtype,
is_datetime64_dtype,
is_datetime64tz_dtype,
is_dict_like,
is_extension_array_dtype,
Expand Down Expand Up @@ -7035,7 +7034,7 @@ def interpolate(
methods = {"index", "values", "nearest", "time"}
is_numeric_or_datetime = (
is_numeric_dtype(index)
or is_datetime64_dtype(index)
or is_datetime64_any_dtype(index)
or is_timedelta64_dtype(index)
)
if method not in methods and not is_numeric_or_datetime:
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from pandas.core.base import DataError, SpecificationError
import pandas.core.common as com
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame, _shared_docs
from pandas.core.generic import ABCDataFrame, ABCSeries, NDFrame, _shared_docs
from pandas.core.groupby import base
from pandas.core.groupby.groupby import GroupBy, _apply_docs, _transform_template
from pandas.core.index import Index, MultiIndex
Expand Down Expand Up @@ -1025,8 +1025,8 @@ def transform(self, func, *args, **kwargs):
object.__setattr__(group, "name", name)
res = wrapper(group)

if hasattr(res, "values"):
res = res.values
if isinstance(res, (ABCDataFrame, ABCSeries)):
res = res._values

indexer = self._get_index(name)
s = klass(res, indexer)
Expand Down
26 changes: 13 additions & 13 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,19 +489,15 @@ def __new__(
pass
elif inferred != "string":
if inferred.startswith("datetime"):
if (
lib.is_datetime_with_singletz_array(subarr)
or "tz" in kwargs
):
# only when subarr has the same tz
from pandas import DatetimeIndex
from pandas import DatetimeIndex

try:
return DatetimeIndex(
subarr, copy=copy, name=name, **kwargs
)
except OutOfBoundsDatetime:
pass
try:
return DatetimeIndex(subarr, copy=copy, name=name, **kwargs)
except (ValueError, OutOfBoundsDatetime):
# GH 27011
# If we have mixed timezones, just send it
# down the base constructor
pass

elif inferred.startswith("timedelta"):
from pandas import TimedeltaIndex
Expand Down Expand Up @@ -1550,7 +1546,11 @@ def _validate_index_level(self, level):
"Too many levels:" " Index has only 1 level, not %d" % (level + 1)
)
elif level != self.name:
raise KeyError("Level %s must be same as name (%s)" % (level, self.name))
raise KeyError(
"Requested level ({}) does not match index name ({})".format(
level, self.name
)
)

def _get_level_number(self, level):
self._validate_index_level(level)
Expand Down
5 changes: 5 additions & 0 deletions pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ensure_platform_int,
is_bool_dtype,
is_extension_array_dtype,
is_integer,
is_integer_dtype,
is_list_like,
is_object_dtype,
Expand Down Expand Up @@ -402,6 +403,10 @@ def unstack(obj, level, fill_value=None):
else:
level = level[0]

# Prioritize integer interpretation (GH #21677):
if not is_integer(level) and not level == "__placeholder__":
level = obj.index._get_level_number(level)

if isinstance(obj, DataFrame):
if isinstance(obj.index, MultiIndex):
return _unstack_frame(obj, level, fill_value=fill_value)
Expand Down
8 changes: 6 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,9 @@ def real(self):
.. deprecated 0.25.0
"""
warnings.warn(
"`real` has be deprecated and will be removed in a " "future verison",
"`real` is deprecated and will be removed in a future version. "
"To eliminate this warning for a Series `ser`, use "
"`np.real(ser.to_numpy())` or `ser.to_numpy().real`.",
FutureWarning,
stacklevel=2,
)
Expand All @@ -976,7 +978,9 @@ def imag(self):
.. deprecated 0.25.0
"""
warnings.warn(
"`imag` has be deprecated and will be removed in a " "future verison",
"`imag` is deprecated and will be removed in a future version. "
"To eliminate this warning for a Series `ser`, use "
"`np.imag(ser.to_numpy())` or `ser.to_numpy().imag`.",
FutureWarning,
stacklevel=2,
)
Expand Down
16 changes: 5 additions & 11 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from functools import partial
from io import StringIO
import re
from shutil import get_terminal_size
from unicodedata import east_asian_width

Expand Down Expand Up @@ -1584,17 +1585,10 @@ def _trim_zeros_complex(str_complexes, na_rep="NaN"):
Separates the real and imaginary parts from the complex number, and
executes the _trim_zeros_float method on each of those.
"""

def separate_and_trim(str_complex, na_rep):
num_arr = str_complex.split("+")
return (
_trim_zeros_float([num_arr[0]], na_rep)
+ ["+"]
+ _trim_zeros_float([num_arr[1][:-1]], na_rep)
+ ["j"]
)

return ["".join(separate_and_trim(x, na_rep)) for x in str_complexes]
return [
"".join(_trim_zeros_float(re.split(r"([j+-])", x), na_rep))
for x in str_complexes
]


def _trim_zeros_float(str_floats, na_rep="NaN"):
Expand Down
Loading