question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

read_csv(parse_dates=True) failure

See original GitHub issue

from 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:closed
  • Created 11 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
changhiskhancommented, Aug 27, 2012

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:

One can indeed look at it from two ways, and fix by updating the docstring 😃

— Reply to this email directly or view it on GitHub.

0reactions
valentas-kurauskascommented, Jun 22, 2015

very non-intuitive…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found