Skip to content

PERF: fixed performance degration becasue doesn't slice values array in to_native_types of DateTimeBlock #25765

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 2 commits into from
Apr 19, 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: 18 additions & 0 deletions asv_bench/benchmarks/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ def time_frame_date_formatting(self):
self.data.to_csv(self.fname, date_format='%Y%m%d')


class ToCSVDatetimeBig(BaseIO):

fname = '__test__.csv'
timeout = 1500
params = [1000, 10000, 100000]
param_names = ['obs']

def setup(self, obs):
d = '2018-11-29'
dt = '2018-11-26 11:18:27.0'
self.data = DataFrame({'dt': [np.datetime64(dt)] * obs,
'd': [np.datetime64(d)] * obs,
'r': [np.random.uniform()] * obs})

def time_frame(self, obs):
self.data.to_csv(self.fname)


class StringIORewind:

def data(self, stringio_object):
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ Performance Improvements
- Improved performance of :meth:`pandas.core.groupby.GroupBy.quantile` (:issue:`20405`)
- Improved performance of :meth:`read_csv` by faster tokenizing and faster parsing of small float numbers (:issue:`25784`)
- Improved performance of :meth:`read_csv` by faster parsing of N/A and boolean values (:issue:`25804`)
- Improved performance of :meth:DataFrame.`to_csv` when write datetime dtype data (:issue:`25708`)

.. _whatsnew_0250.bug_fixes:

Expand Down
1 change: 1 addition & 0 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,7 @@ def to_native_types(self, slicer=None, na_rep=None, date_format=None,
i8values = self.values.view('i8')

if slicer is not None:
values = values[..., slicer]
i8values = i8values[..., slicer]

from pandas.io.formats.format import _get_format_datetime64_from_values
Expand Down