Skip to content

ASV: more for str.cat #22652

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 5 commits into from
Sep 14, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add comment to explain choice of parameters [ci skip]
  • Loading branch information
h-vetinari committed Sep 13, 2018
commit 4d14cfaecd1521ebc276d606cab86b07f227d6a5
4 changes: 4 additions & 0 deletions asv_bench/benchmarks/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def setup(self, others, sep, na_rep, na_frac):
if others is not None else None)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason you don't just use 0 instead of None as the parametrized argument? Would get rid of the need for a condition here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to 0 for consistency/legibility, but still need the condition, as pd.DataFrame({'i' : ... for i in range(0)}) would yield a DataFrame (but str.cat needs others=None to self-concatenate).


def time_cat(self, others, sep, na_rep, na_frac):
# before the concatenation (one caller + others columns), the total
# expected fraction of rows containing any NaN is:
# reduce(lambda t, _: t + (1 - t) * na_frac, range(others + 1), 0)
# for others=5 and na_frac=0.1, this works out to ~47%
self.s.str.cat(self.others, sep=sep, na_rep=na_rep)


Expand Down