8000 PERF: PeriodIndex.dropna, difference, take by jbrockmendel · Pull Request #23095 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

PERF: PeriodIndex.dropna, difference, take #23095

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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 asvs
  • Loading branch information
jbrockmendel committed Oct 11, 2018
commit ba80015c70ab9ec968c33749569febfeb44f8b84
11 changes: 11 additions & 0 deletions asv_bench/benchmarks/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def time_value_counts(self, typ):
class Indexing(object):

goal_time = 0.2
pi_with_nas = PeriodIndex(['1985Q1', 'NaT', '1985Q2'] * 1000, freq='Q')
pi_diff = PeriodIndex(['1985Q1', 'NaT', '1985Q3'] * 1000, freq='Q')
Copy link
Member Author

Choose a reason for hiding this comment

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

setup gets called with every round of time_foo. Doing this here is analogous to calling setup_class once.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

setup_cache pickles and then loads in each step of the loop


def setup(self):
self.index = PeriodIndex(start='1985', periods=1000, freq='D')
Expand All @@ -122,3 +124,12 @@ def time_intersection(self):

def time_unique(self):
self.index.unique()

def time_dropna(self):
self.pi_with_nas.dropna()

def time_difference(self):
self.pi_with_nas.difference(self.pi_diff)

def time_symmetric_difference(self):
self.pi_with_nas.symmetric_difference(self.pi_diff)
4 changes: 2 additions & 2 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ def __array_wrap__(self, result, context=None):
"""
if isinstance(context, tuple) and len(context) > 0:
func = context[0]
if (func is np.add):
if func is np.add:
pass
elif (func is np.subtract):
elif func is np.subtract:
name = self.name
left = context[1][0]
right = context[1][1]
Expand Down
0