Reputation: 5779
I have a csv file with the following format:
10/09/2009,08:16,99.835,99.835,99.835,99.835,2
How do I call pandas.read_csv
on such a file so that it parses the first 2 columns as a datetime index?
Upvotes: 1
Views: 2591
Reputation: 19124
Use the parse_dates
kwarg in the read_csv function. See the docs.
df = pd.read_csv(filepath_goes_here, sep=',', parse_dates={'dt': [0, 1]}).set_index('dt')
You can also use the date_parser
kwarg if you have dates in nonstandard formats (the ones in this example are standard).
Upvotes: 4