Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff6d7eb

Browse files
committed
Merge pull request matplotlib#1210 from dmcdougall/csv2rec_date
Add dateutil kwargs to csv2rec
2 parents 8605579 + 227c10b commit ff6d7eb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/matplotlib/mlab.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ def extract(r):
20922092

20932093
def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
20942094
converterd=None, names=None, missing='', missingd=None,
2095-
use_mrecords=False):
2095+
use_mrecords=False, dayfirst=False, yearfirst=False):
20962096
"""
20972097
Load data from comma/space/tab delimited file in *fname* into a
20982098
numpy record array and return the record array.
@@ -2131,6 +2131,14 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
21312131
21322132
- *use_mrecords*: if True, return an mrecords.fromrecords record array if any of the data are missing
21332133
2134+
- *dayfirst*: default is False so that MM-DD-YY has precedence over
2135+
DD-MM-YY. See http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
2136+
for further information.
2137+
2138+
- *yearfirst*: default is False so that MM-DD-YY has precedence over
2139+
YY-MM-DD. See http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
2140+
for further information.
2141+
21342142
If no rows are found, *None* is returned -- see :file:`examples/loadrec.py`
21352143
"""
21362144

@@ -2218,7 +2226,7 @@ def mybool(x):
22182226

22192227
def mydate(x):
22202228
# try and return a date object
2221-
d = dateparser(x)
2229+
d = dateparser(x, dayfirst=dayfirst, yearfirst=yearfirst)
22222230

22232231
if d.hour>0 or d.minute>0 or d.second>0:
22242232
raise ValueError('not a date')

0 commit comments

Comments
 (0)