diff --git a/asv_bench/benchmarks/algorithms.py b/asv_bench/benchmarks/algorithms.py index 1ab88dc9f9e6d..7dcd7b284d66d 100644 --- a/asv_bench/benchmarks/algorithms.py +++ b/asv_bench/benchmarks/algorithms.py @@ -1,10 +1,11 @@ -import warnings from importlib import import_module import numpy as np + import pandas as pd from pandas.util import testing as tm + for imp in ['pandas.util', 'pandas.tools.hashing']: try: hashing = import_module(imp) @@ -73,10 +74,6 @@ def setup(self): self.uniques = tm.makeStringIndex(1000).values self.all = self.uniques.repeat(10) - def time_match_string(self): - with warnings.catch_warnings(record=True): - pd.match(self.all, self.uniques) - class Hashing(object): diff --git a/asv_bench/benchmarks/frame_methods.py b/asv_bench/benchmarks/frame_methods.py index dcecaf60ed578..3c0dd646aa502 100644 --- a/asv_bench/benchmarks/frame_methods.py +++ b/asv_bench/benchmarks/frame_methods.py @@ -1,10 +1,10 @@ import string -import warnings import numpy as np + +from pandas import ( + DataFrame, MultiIndex, NaT, Series, date_range, isnull, period_range) import pandas.util.testing as tm -from pandas import (DataFrame, Series, MultiIndex, date_range, period_range, - isnull, NaT) class GetNumericData(object): @@ -61,9 +61,6 @@ def time_reindex_axis1(self): def time_reindex_both_axes(self): self.df.reindex(index=self.idx, columns=self.idx) - def time_reindex_both_axes_ix(self): - self.df.ix[self.idx, self.idx] - def time_reindex_upcast(self): self.df2.reindex(np.random.permutation(range(1200))) diff --git a/asv_bench/benchmarks/groupby.py b/asv_bench/benchmarks/groupby.py index dbd79185ec006..ee5ae69555d16 100644 --- a/asv_bench/benchmarks/groupby.py +++ b/asv_bench/benchmarks/groupby.py @@ -1,11 +1,13 @@ -import warnings -from string import ascii_letters -from itertools import product from functools import partial +from itertools import product +from string import ascii_letters +import warnings import numpy as np -from pandas import (DataFrame, Series, MultiIndex, date_range, period_range, - TimeGrouper, Categorical, Timestamp) + +from pandas import ( + Categorical, DataFrame, MultiIndex, Series, TimeGrouper, Timestamp, + date_range, period_range) import pandas.util.testing as tm @@ -210,7 +212,7 @@ def time_multi_int_nunique(self, df): class AggFunctions(object): - def setup_cache(): + def setup_cache(self): N = 10**5 fac1 = np.array(['A', 'B', 'C'], dtype='O') fac2 = np.array(['one', 'two'], dtype='O') diff --git a/pandas/core/sparse/scipy_sparse.py b/pandas/core/sparse/scipy_sparse.py index ab4fdeb05f8f1..2d0ce2d5e5951 100644 --- a/pandas/core/sparse/scipy_sparse.py +++ b/pandas/core/sparse/scipy_sparse.py @@ -58,15 +58,7 @@ def _get_label_to_i_dict(labels, sort_labels=False): return (d) def _get_index_subset_to_coord_dict(index, subset, sort_labels=False): - def robust_get_level_values(i): - # if index has labels (that are not None) use those, - # else use the level location - try: - return index.get_level_values(index.names[i]) - except KeyError: - return index.get_level_values(i) - - ilabels = list(zip(*[robust_get_level_values(i) for i in subset])) + ilabels = list(zip(*[index._get_level_values(i) for i in subset])) labels_to_i = _get_label_to_i_dict(ilabels, sort_labels=sort_labels) labels_to_i = Series(labels_to_i) diff --git a/pandas/io/formats/html.py b/pandas/io/formats/html.py index bf92ce7ee0f67..6425e655959bd 100644 --- a/pandas/io/formats/html.py +++ b/pandas/io/formats/html.py @@ -5,7 +5,6 @@ from __future__ import print_function -from distutils.version import LooseVersion from textwrap import dedent from pandas.compat import OrderedDict, lzip, map, range, u, unichr, zip @@ -161,15 +160,7 @@ def write_result(self, buf): _classes.extend(self.classes) if self.notebook: - div_style = '' - try: - import IPython - if IPython.__version__ < LooseVersion('3.0.0'): - div_style = ' style="max-width:1500px;overflow:auto;"' - except (ImportError, AttributeError): - pass - - self.write(''.format(style=div_style)) + self.write('
') self.write_style() diff --git a/pandas/tests/io/conftest.py b/pandas/tests/io/conftest.py index b0cdbe2b5bedb..928519d39aed3 100644 --- a/pandas/tests/io/conftest.py +++ b/pandas/tests/io/conftest.py @@ -37,6 +37,11 @@ def s3_resource(tips_file, jsonl_file): """ pytest.importorskip('s3fs') boto3 = pytest.importorskip('boto3') + # GH-24092. See if boto.plugin skips the test or fails. + try: + pytest.importorskip("boto.plugin") + except AttributeError: + raise pytest.skip("moto/moto error") moto = pytest.importorskip('moto') test_s3_files = [ diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index d047970ce2f08..ed954c76294b6 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -846,6 +846,7 @@ def test_misc_example(self): assert_frame_equal(result, expected) @network + @pytest.mark.single def test_round_trip_exception_(self): # GH 3867 csv = 'https://raw.github.com/hayd/lahman2012/master/csvs/Teams.csv' @@ -856,6 +857,7 @@ def test_round_trip_exception_(self): index=df.index, columns=df.columns), df) @network + @pytest.mark.single def test_url(self): url = 'https://api.github.com/repos/pandas-dev/pandas/issues?per_page=5' # noqa result = read_json(url, convert_dates=True) diff --git a/pandas/tests/sparse/frame/test_to_from_scipy.py b/pandas/tests/sparse/frame/test_to_from_scipy.py index 1a10ff83d3097..e5c50e9574f90 100644 --- a/pandas/tests/sparse/frame/test_to_from_scipy.py +++ b/pandas/tests/sparse/frame/test_to_from_scipy.py @@ -1,5 +1,6 @@ import pytest import numpy as np +import pandas as pd from pandas.util import testing as tm from pandas import SparseDataFrame, SparseSeries from pandas.core.sparse.api import SparseDtype @@ -168,3 +169,16 @@ def test_from_scipy_fillna(spmatrix): expected[col].fill_value = -1 tm.assert_sp_frame_equal(sdf, expected) + + +def test_index_names_multiple_nones(): + # https://github.com/pandas-dev/pandas/pull/24092 + sparse = pytest.importorskip("scipy.sparse") + + s = (pd.Series(1, index=pd.MultiIndex.from_product([['A', 'B'], [0, 1]])) + .to_sparse()) + result, _, _ = s.to_coo() + assert isinstance(result, sparse.coo_matrix) + result = result.toarray() + expected = np.ones((2, 2), dtype="int64") + tm.assert_numpy_array_equal(result, expected) diff --git a/setup.cfg b/setup.cfg index 25f713822f127..44df79d1b60d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -361,5 +361,40 @@ skip= pandas/tests/computation/test_compat.py, pandas/tests/computation/test_eval.py, pandas/types/common.py, - pandas/tests/extension/arrow/test_bool.py - doc/source/conf.py + pandas/tests/extension/arrow/test_bool.py, + doc/source/conf.py, + asv_bench/benchmarks/algorithms.py, + asv_bench/benchmarks/attrs_caching.py, + asv_bench/benchmarks/binary_ops.py, + asv_bench/benchmarks/categoricals.py, + asv_bench/benchmarks/ctors.py, + asv_bench/benchmarks/eval.py, + asv_bench/benchmarks/frame_ctor.py, + asv_bench/benchmarks/frame_methods.py, + asv_bench/benchmarks/gil.py, + asv_bench/benchmarks/groupby.py, + asv_bench/benchmarks/index_object.py, + asv_bench/benchmarks/indexing.py, + asv_bench/benchmarks/inference.py, + asv_bench/benchmarks/io/csv.py, + asv_bench/benchmarks/io/excel.py, + asv_bench/benchmarks/io/hdf.py, + asv_bench/benchmarks/io/json.py, + asv_bench/benchmarks/io/msgpack.py, + asv_bench/benchmarks/io/pickle.py, + asv_bench/benchmarks/io/sql.py, + asv_bench/benchmarks/io/stata.py, + asv_bench/benchmarks/join_merge.py, + asv_bench/benchmarks/multiindex_object.py, + asv_bench/benchmarks/panel_ctor.py, + asv_bench/benchmarks/panel_methods.py, + asv_bench/benchmarks/plotting.py, + asv_bench/benchmarks/reindex.py, + asv_bench/benchmarks/replace.py, + asv_bench/benchmarks/reshape.py, + asv_bench/benchmarks/rolling.py, + asv_bench/benchmarks/series_methods.py, + asv_bench/benchmarks/sparse.py, + asv_bench/benchmarks/stat_ops.py, + asv_bench/benchmarks/timeseries.py +