Skip to content

ASV: added benchamark tests for DataFrame.to_numpy() and .values #36452

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 1 commit into from
Sep 19, 2020
Merged
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
40 changes: 40 additions & 0 deletions asv_bench/benchmarks/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,46 @@ def time_to_html_mixed(self):
self.df2.to_html()


class ToNumpy:
def setup(self):
N = 10000
M = 10
self.df_tall = DataFrame(np.random.randn(N, M))
self.df_wide = DataFrame(np.random.randn(M, N))
self.df_mixed_tall = self.df_tall.copy()
self.df_mixed_tall["foo"] = "bar"
self.df_mixed_tall[0] = period_range("2000", periods=N)
self.df_mixed_tall[1] = range(N)
self.df_mixed_wide = self.df_wide.copy()
self.df_mixed_wide["foo"] = "bar"
self.df_mixed_wide[0] = period_range("2000", periods=M)
self.df_mixed_wide[1] = range(M)

def time_to_numpy_tall(self):
self.df_tall.to_numpy()

def time_to_numpy_wide(self):
self.df_wide.to_numpy()

def time_to_numpy_mixed_tall(self):
self.df_mixed_tall.to_numpy()

def time_to_numpy_mixed_wide(self):
self.df_mixed_wide.to_numpy()

def time_values_tall(self):
self.df_tall.values

def time_values_wide(self):
self.df_wide.values

def time_values_mixed_tall(self):
self.df_mixed_tall.values

def time_values_mixed_wide(self):
self.df_mixed_wide.values


class Repr:
def setup(self):
nrows = 10000
Expand Down