Skip to content

PERF: Suppress ix warnings benchmarks #27304

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 7 commits into from
Jul 9, 2019
Merged
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
18 changes: 11 additions & 7 deletions asv_bench/benchmarks/frame_methods.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
import string

import numpy as np
Expand Down Expand Up @@ -320,9 +321,10 @@ class Dropna:

def setup(self, how, axis):
self.df = DataFrame(np.random.randn(10000, 1000))
self.df.ix[50:1000, 20:50] = np.nan
self.df.ix[2000:3000] = np.nan
self.df.ix[:, 60:70] = np.nan
with warnings.catch_warnings(record=True):
self.df.ix[50:1000, 20:50] = np.nan
self.df.ix[2000:3000] = np.nan
self.df.ix[:, 60:70] = np.nan
self.df_mixed = self.df.copy()
self.df_mixed["foo"] = "bar"

Expand All @@ -340,9 +342,10 @@ class Count:

def setup(self, axis):
self.df = DataFrame(np.random.randn(10000, 1000))
self.df.ix[50:1000, 20:50] = np.nan
self.df.ix[2000:3000] = np.nan
self.df.ix[:, 60:70] = np.nan
with warnings.catch_warnings(record=True):
self.df.ix[50:1000, 20:50] = np.nan
self.df.ix[2000:3000] = np.nan
self.df.ix[:, 60:70] = np.nan
self.df_mixed = self.df.copy()
self.df_mixed["foo"] = "bar"

Expand Down Expand Up @@ -561,7 +564,8 @@ def setup(self):
self.df = DataFrame(np.random.randn(10, 10000))

def time_frame_get_dtype_counts(self):
self.df.get_dtype_counts()
with warnings.catch_warnings(record=True):
self.df.get_dtype_counts()

def time_info(self):
self.df.info()
Expand Down
48 changes: 29 additions & 19 deletions asv_bench/benchmarks/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ def time_iloc_slice(self, index, index_structure):
self.data.iloc[:800000]

def time_ix_array(self, index, index_structure):
self.data.ix[self.array]
with warnings.catch_warnings(record=True):
self.data.ix[self.array]

def time_ix_list_like(self, index, index_structure):
self.data.ix[[800000]]
with warnings.catch_warnings(record=True):
self.data.ix[[800000]]

def time_ix_scalar(self, index, index_structure):
self.data.ix[800000]
with warnings.catch_warnings(record=True):
self.data.ix[800000]

def time_ix_slice(self, index, index_structure):
self.data.ix[:800000]
with warnings.catch_warnings(record=True):
self.data.ix[:800000]

def time_loc_array(self, index, index_structure):
self.data.loc[self.array]
Expand Down Expand Up @@ -131,7 +135,8 @@ class DataFrameStringIndexing:
def setup(self):
index = tm.makeStringIndex(1000)
columns = tm.makeStringIndex(30)
self.df = DataFrame(np.random.randn(1000, 30), index=index, columns=columns)
with warnings.catch_warnings(record=True):
self.df = DataFrame(np.random.randn(1000, 30), index=index, columns=columns)
self.idx_scalar = index[100]
self.col_scalar = columns[10]
self.bool_indexer = self.df[self.col_scalar] > 0
Expand All @@ -142,7 +147,8 @@ def time_get_value(self):
self.df.get_value(self.idx_scalar, self.col_scalar)

def time_ix(self):
self.df.ix[self.idx_scalar, self.col_scalar]
with warnings.catch_warnings(record=True):
self.df.ix[self.idx_scalar, self.col_scalar]

def time_loc(self):
self.df.loc[self.idx_scalar, self.col_scalar]
Expand Down Expand Up @@ -206,24 +212,27 @@ def setup(self):
self.df = DataFrame(self.s)

n = 100000
self.mdt = DataFrame(
{
"A": np.random.choice(range(10000, 45000, 1000), n),
"B": np.random.choice(range(10, 400), n),
"C": np.random.choice(range(1, 150), n),
"D": np.random.choice(range(10000, 45000), n),
"x": np.random.choice(range(400), n),
"y": np.random.choice(range(25), n),
}
)
with warnings.catch_warnings(record=True):
self.mdt = DataFrame(
{
"A": np.random.choice(range(10000, 45000, 1000), n),
"B": np.random.choice(range(10, 400), n),
"C": np.random.choice(range(1, 150), n),
"D": np.random.choice(range(10000, 45000), n),
"x": np.random.choice(range(400), n),
"y": np.random.choice(range(25), n),
}
)
self.idx = IndexSlice[20000:30000, 20:30, 35:45, 30000:40000]
self.mdt = self.mdt.set_index(["A", "B", "C", "D"]).sort_index()

def time_series_ix(self):
self.s.ix[999]
with warnings.catch_warnings(record=True):
self.s.ix[999]

def time_frame_ix(self):
self.df.ix[999]
with warnings.catch_warnings(record=True):
self.df.ix[999]

def time_index_slice(self):
self.mdt.loc[self.idx, :]
Expand Down Expand Up @@ -300,7 +309,8 @@ def time_lookup_iloc(self, s):
s.iloc

def time_lookup_ix(self, s):
s.ix
with warnings.catch_warnings(record=True):
s.ix

def time_lookup_loc(self, s):
s.loc
Expand Down
4 changes: 3 additions & 1 deletion asv_bench/benchmarks/io/msgpack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
import numpy as np
from pandas import DataFrame, date_range, read_msgpack
import pandas.util.testing as tm
Expand All @@ -16,7 +17,8 @@ def setup(self):
index=date_range("20000101", periods=N, freq="H"),
)
self.df["object"] = tm.makeStringIndex(N)
self.df.to_msgpack(self.fname)
with warnings.catch_warnings(record=True):
self.df.to_msgpack(self.fname)

def time_read_msgpack(self):
read_msgpack(self.fname)
Expand Down
1 change: 1 addition & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5603,6 +5603,7 @@ def get_dtype_counts(self):
FutureWarning,
stacklevel=2,
)

from pandas import Series

return Series(self._data.get_dtype_counts())
Expand Down