Skip to content

PERF: vbench for time-series index assignment in frame (GH5320) #5321

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
Oct 25, 2013
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
6 changes: 5 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,11 @@ def insert(self, loc, column, value, allow_duplicates=False):
def _sanitize_column(self, key, value):
# Need to make sure new columns (which go into the BlockManager as new
# blocks) are always copied
if _is_sequence(value):

# dont' need further processing on an equal index
if isinstance(value, Index) and (not len(self.index) or value.equals(self.index)):
value = value.values.copy()
elif isinstance(value, Series) or _is_sequence(value):
is_frame = isinstance(value, DataFrame)
if isinstance(value, Series) or is_frame:
if value.index.equals(self.index) or not len(self.index):
Expand Down
15 changes: 15 additions & 0 deletions vb_suite/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ def j():
frame_getitem_single_column2 = Benchmark('j()', setup,
start_date=datetime(2010, 6, 1))

#----------------------------------------------------------------------
# assignment

setup = common_setup + """
idx = date_range('1/1/2000', periods=100000, freq='D')
df = DataFrame(randn(100000, 1),columns=['A'],index=idx)
def f(x):
x = x.copy()
x['date'] = x.index
"""

frame_assign_timeseries_index = Benchmark('f(df)', setup,
start_date=datetime(2013, 10, 1))


#----------------------------------------------------------------------
# to_string

Expand Down
4 changes: 2 additions & 2 deletions vb_suite/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ def date_range(start=None, end=None, periods=None, freq=None):
# tz_localize with infer argument. This is an attempt to emulate the results
# of read_csv with duplicated data. Not passing infer_dst will fail
setup = common_setup + """
dst_rng = date_range('10/29/2000 1:00:00',
dst_rng = date_range('10/29/2000 1:00:00',
'10/29/2000 1:59:59', freq='S')
index = date_range('10/29/2000', '10/29/2000 00:59:59', freq='S')
index = index.append(dst_rng)
index = index.append(dst_rng)
index = index.append(date_range('10/29/2000 2:00:00',
index = index.append(date_range('10/29/2000 2:00:00',
'10/29/2000 3:00:00', freq='S'))
"""

Expand Down