Skip to content

CLN: assorted cleanups #30473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d181280
CLN: assorted
jbrockmendel Dec 19, 2019
77102c5
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 19, 2019
30324b2
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 20, 2019
a8c261b
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 20, 2019
7bf6b6f
CLN old comment
jbrockmendel Dec 20, 2019
a33a55b
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 20, 2019
5a4cd67
request from #30336
jbrockmendel Dec 20, 2019
f6f9678
cleanup
jbrockmendel Dec 21, 2019
1f20263
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 21, 2019
7884e59
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 23, 2019
628ad45
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 23, 2019
77201d7
fix typo form 30414
jbrockmendel Dec 23, 2019
ca8f494
remove binstar
jbrockmendel Dec 23, 2019
cb46c3e
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 23, 2019
0b31dac
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 24, 2019
93b901b
catch trueiv warnings, taken from #30345
jbrockmendel Dec 24, 2019
61d2e24
dont catch importerror
jbrockmendel Dec 24, 2019
5e5e0e5
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 24, 2019
3c272fa
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 24, 2019
73d4f99
revert bit in another PR
jbrockmendel Dec 24, 2019
5ae47e3
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 24, 2019
8b2c90c
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 25, 2019
b0414e1
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 25, 2019
751c9e9
black fixup
jbrockmendel Dec 25, 2019
fc8d207
Merge branch 'master' of https://github.com/pandas-dev/pandas into co…
jbrockmendel Dec 26, 2019
9508b8d
remove runtime imports
jbrockmendel Dec 26, 2019
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
28 changes: 0 additions & 28 deletions .binstar.yml

This file was deleted.

4 changes: 2 additions & 2 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- :meth:`Series.where` with ``Categorical`` dtype (or :meth:`DataFrame.where` with ``Categorical`` column) no longer allows setting new categories (:issue:`24114`)
- :class:`DatetimeIndex`, :class:`TimedeltaIndex`, and :class:`PeriodIndex` constructors no longer allow ``start``, ``end``, and ``periods`` keywords, use :func:`date_range`, :func:`timedelta_range`, and :func:`period_range` instead (:issue:`23919`)
- :class:`DatetimeIndex` and :class:`TimedeltaIndex` constructors no longer have a ``verify_integrity`` keyword argument (:issue:`23919`)
- ``pandas.core.internals.blocks.make_block`` no longer accepts the "fastpath" keyword(:issue:`19265`)
- :meth:`Block.make_block_same_class` no longer accepts the "dtype" keyword(:issue:`19434`)
- ``pandas.core.internals.blocks.make_block`` no longer accepts the "fastpath" keyword (:issue:`19265`)
- :meth:`Block.make_block_same_class` no longer accepts the "dtype" keyword (:issue:`19434`)
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
- Removed the previously deprecated :meth:`MultiIndex.to_hierarchical` (:issue:`21613`)
- Removed the previously deprecated :attr:`MultiIndex.labels`, use :attr:`MultiIndex.codes` instead (:issue:`23752`)
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/reshape.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def unstack(reshape_t[:, :] values, uint8_t[:] mask,
Py_ssize_t stride, Py_ssize_t length, Py_ssize_t width,
reshape_t[:, :] new_values, uint8_t[:, :] new_mask):
"""
transform long sorted_values to wide new_values
Transform long values to wide new_values.

Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ def _add_offset(self, offset):
PerformanceWarning,
)
result = self.astype("O") + offset
if len(self) == 0:
# _from_sequence won't be able to infer self.tz
if not len(self):
# GH#30336 _from_sequence won't be able to infer self.tz
return type(self)._from_sequence(result).tz_localize(self.tz)

return type(self)._from_sequence(result, freq="infer")
Expand Down
6 changes: 4 additions & 2 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,16 +741,17 @@ def copy(self, deep=True):

Parameters
----------
deep : boolean o rstring, default True
deep : bool or string, default True
If False, return shallow copy (do not copy data)
If 'all', copy data and a deep copy of the index

Returns
-------
copy : BlockManager
BlockManager
"""
# this preserves the notion of view copying of axes
if deep:
# hit in e.g. tests.io.json.test_pandas

def copy_func(ax):
if deep == "all":
Expand All @@ -761,6 +762,7 @@ def copy_func(ax):
new_axes = [copy_func(ax) for ax in self.axes]
else:
new_axes = list(self.axes)

res = self.apply("copy", deep=deep)
res.axes = new_axes
return res
Expand Down
2 changes: 0 additions & 2 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2227,8 +2227,6 @@ class PythonParser(ParserBase):
def __init__(self, f, **kwds):
"""
Workhorse function for processing nested list into DataFrame

Should be replaced by np.genfromtxt eventually?
"""
ParserBase.__init__(self, kwds)

Expand Down
6 changes: 0 additions & 6 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ def _iter_data(self, data=None, keep_index=False, fillna=None):
if fillna is not None:
data = data.fillna(fillna)

# TODO: unused?
# if self.sort_columns:
# columns = com.try_sort(data.columns)
# else:
# columns = data.columns

for col, values in data.items():
if keep_index is True:
yield col, values
Expand Down
20 changes: 14 additions & 6 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,25 +1206,33 @@ def test_truediv(self):
ex = "s / 1"
d = {"s": s} # noqa

res = self.eval(ex, truediv=False)
# FutureWarning: The `truediv` parameter in pd.eval is deprecated and will be
# removed in a future version.
with tm.assert_produces_warning(FutureWarning):
res = self.eval(ex, truediv=False)
tm.assert_numpy_array_equal(res, np.array([1.0]))

res = self.eval(ex, truediv=True)
with tm.assert_produces_warning(FutureWarning):
res = self.eval(ex, truediv=True)
tm.assert_numpy_array_equal(res, np.array([1.0]))

res = self.eval("1 / 2", truediv=True)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("1 / 2", truediv=True)
expec = 0.5
assert res == expec

res = self.eval("1 / 2", truediv=False)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("1 / 2", truediv=False)
expec = 0.5
assert res == expec

res = self.eval("s / 2", truediv=False)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("s / 2", truediv=False)
expec = 0.5
assert res == expec

res = self.eval("s / 2", truediv=True)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("s / 2", truediv=True)
expec = 0.5
assert res == expec

Expand Down
21 changes: 9 additions & 12 deletions pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,18 +1123,15 @@ def test_is_string_array(self):
def test_to_object_array_tuples(self):
r = (5, 6)
values = [r]
result = lib.to_object_array_tuples(values)

try:
# make sure record array works
from collections import namedtuple

record = namedtuple("record", "x y")
r = record(5, 6)
values = [r]
result = lib.to_object_array_tuples(values) # noqa
except ImportError:
pass
lib.to_object_array_tuples(values)

# make sure record array works
from collections import namedtuple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move to top


record = namedtuple("record", "x y")
r = record(5, 6)
values = [r]
lib.to_object_array_tuples(values)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to compare if you can


def test_object(self):

Expand Down
10 changes: 6 additions & 4 deletions pandas/tests/extension/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def data_missing(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
if _np_version_under1p16:
raise pytest.skip("Skipping for NumPy <1.16")
return PandasArray(np.array([np.nan, (1,)]))
return PandasArray(np.array([np.nan, (1,)], dtype=object))
return PandasArray(np.array([np.nan, 1.0]))


Expand All @@ -78,7 +78,7 @@ def data_for_sorting(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
# Use an empty tuple for first element, then remove,
# to disable np.array's shape inference.
return PandasArray(np.array([(), (2,), (3,), (1,)])[1:])
return PandasArray(np.array([(), (2,), (3,), (1,)], dtype=object)[1:])
return PandasArray(np.array([1, 2, 0]))


Expand All @@ -90,7 +90,7 @@ def data_missing_for_sorting(allow_in_pandas, dtype):
A < B and NA missing.
"""
if dtype.numpy_dtype == "object":
return PandasArray(np.array([(1,), np.nan, (0,)]))
return PandasArray(np.array([(1,), np.nan, (0,)], dtype=object))
return PandasArray(np.array([1, np.nan, 0]))


Expand All @@ -106,7 +106,9 @@ def data_for_grouping(allow_in_pandas, dtype):
a, b, c = (1,), (2,), (3,)
else:
a, b, c = np.arange(3)
return PandasArray(np.array([b, b, np.nan, np.nan, a, a, b, c]))
return PandasArray(
np.array([b, b, np.nan, np.nan, a, a, b, c], dtype=dtype.numpy_dtype)
)


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_to_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_to_records_with_unicode_index(self):
tm.assert_almost_equal(result, expected)

def test_to_records_with_unicode_column_names(self):
# xref GH#2407
# xref issue: https://github.com/numpy/numpy/issues/2407
# Issue GH#11879. to_records used to raise an exception when used
# with column names containing non-ascii characters in Python 2
result = DataFrame(data={"accented_name_é": [1.0]}).to_records()
Expand Down