python pandas read_csv how to parse microsecond
Question: I have csv file with microsecond as time.

    
    
    Time,Bid
    
    2014-03-03 23:30:30:224323224323,0.8925
    
    2014-03-03 23:30:30:224390224390,0.892525
    
    2014-03-03 23:30:30:224408224408,0.892525
    
    2014-03-03 23:30:30:364299364299,0.892525
    

how do i parse microsecond into Time index with read_csv() or other function
read_json maybe?

Thank you!


Answer: Following on from @Jeff's comment you can do the following:

    
    
    In [29]:
    import pandas as pd
    # specifically set the Time column to object dtype
    df = pd.read_csv(r'c:\data\temp1.txt', dtype={'Time':object})
    df
    
    Out[29]:
    
                                   Time       Bid
    0  2014-03-03 23:30:30:224323224323  0.892500
    1  2014-03-03 23:30:30:224390224390  0.892525
    2  2014-03-03 23:30:30:224408224408  0.892525
    3  2014-03-03 23:30:30:364299364299  0.892525
    
    [4 rows x 2 columns]
    
    In [32]:
    # trim the erroneous data
    df.Time=df.Time.apply(lambda x: x[:-6])
    # now apply to_datetime and pass the format string
    df.Time = pd.to_datetime(df.Time, format='%Y-%m-%d %H:%M:%S:%f')
    df.dtypes
    
    Out[32]:
    
    Time    datetime64[ns]
    Bid            float64
    dtype: object
    

