Skip to content
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
29 changes: 27 additions & 2 deletions asv_bench/benchmarks/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np
import pandas.util.testing as tm
from pandas import DataFrame, Categorical, date_range, read_csv
from pandas import DataFrame, Categorical, date_range, read_csv, to_datetime
from pandas.io.parsers import _parser_defaults
from io import StringIO

Expand Down Expand Up @@ -273,7 +273,7 @@ def mem_parser_chunks(self):

class ReadCSVParseSpecialDate(StringIORewind):
params = (['mY', 'mdY', 'hm'],)
params_name = ['value']
param_names = ['value']
objects = {
'mY': '01-2019\n10-2019\n02/2000\n',
'mdY': '12/02/2010\n',
Expand All @@ -290,4 +290,29 @@ def time_read_special_date(self, value):
names=['Date'], parse_dates=['Date'])


class ParseDateComparison(StringIORewind):
params = ([False, True],)
param_names = ['cache_dates']

def setup(self, cache_dates):
count_elem = 10000
data = '12-02-2010\n' * count_elem
self.StringIO_input = StringIO(data)

def time_read_csv_dayfirst(self, cache_dates):
read_csv(self.data(self.StringIO_input), sep=',', header=None,
names=['Date'], parse_dates=['Date'], cache_dates=cache_dates,
dayfirst=True)

def time_to_datetime_dayfirst(self, cache_dates):
df = read_csv(self.data(self.StringIO_input),
dtype={'date': str}, names=['date'])
to_datetime(df['date'], cache=cache_dates, dayfirst=True)

def time_to_datetime_format_DD_MM_YYYY(self, cache_dates):
df = read_csv(self.data(self.StringIO_input),
dtype={'date': str}, names=['date'])
to_datetime(df['date'], cache=cache_dates, format='%d-%m-%Y')


from ..pandas_vb_common import setup # noqa: F401