read_csv(parse_dates=True) failure
See original GitHub issuefrom stackoverflow
import pandas as pd
from StringIO import StringIO
data = "date,c1\n2012-07-31 02:00,1.1\n2012-07-31 02:15,2.2\n2012-07-31 02:30,3.3\n"
df1 = pd.read_csv(StringIO(data),parse_dates=True).set_index(('date'))
df2 = pd.read_csv(StringIO(data),parse_dates=[0] ).set_index(('date'))
print "df1:\n{index}".format(index=df1.index)
print "df2:\n{index}".format(index=df2.index)
df1 has a index of dtype object.
Issue Analytics
- State:
- Created 11 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Error when parsing timestamp with pandas read_csv
The documentation for read_csv says : boolean : If True -> try parsing the index. list of ints or names -> try parsing...
Read more >pandas.read_csv — pandas 1.5.2 documentation
If True and parse_dates is enabled, pandas will attempt to infer the format of the datetime strings in the columns, and if it...
Read more >4 tricks you should know to parse date columns with Pandas ...
1. Reading date columns from a CSV file. By default, date columns are represented as object when loading data from a CSV file....
Read more >11 Data import - R for Data Science - Hadley Wickham
When you run read_csv() it prints out a column specification that gives the name and type of each column. That's an important part...
Read more >Parse date/times — parse_datetime • readr
row col expected actual #> 1 -- date like %d/%m/%y 01/02/2010 #> [1] NA # Failures ... "32/01/2010"), "%d/%m/%Y") #> Warning: 2 parsing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m guessing originally the choice was made so the reader doesn’t go through and try to convert dates for every single column. Maybe we can add an option to make it do so if you don’t care about the possible performance hit (have to check what the impact would be).
On Aug 27, 2012, at 3:49 PM, Wouter Overmeire notifications@github.com wrote:
very non-intuitive…