python read date and time from csv
Question: my data looks like that:

    
    
    GIdx,Date,num,Time
    1,11/28/2012,20,10:05:50
    1,11/28/2012,20,10:05:50
    2,11/28/2012,20,10:09:24
    2,11/28/2012,20,10:09:24
    2,11/28/2012,20,10:09:25
    2,11/28/2012,20,10:09:25
    2,11/28/2012,20,10:09:26
    3,11/28/2012,20,10:09:34
    3,11/28/2012,20,10:09:34
    

i try to read column **Date** as `datetime` and column **Time** as `time` but
when I check the their type I get `Series`:

    
    
    type(df['Date'])
    
    class pandas.core.series.Series
    
    type(df_original['Time'])
    
    class pandas.core.series.Series
    

I did something like:

    
    
    df=pd.read_csv(filename,sep=",", header = 0, na_values=['NA'])
    


Answer: You can add to [`read_csv`](http://pandas.pydata.org/pandas-
docs/stable/generated/pandas.read_csv.html) parameter `parse_dates` with
columns where are `dates` and `times`:

    
    
    import pandas as pd
    import io
    
    temp=u"""GIdx,Date,num,Time
    1,11/28/2012,20,10:05:50
    1,11/28/2012,20,10:05:50
    2,11/28/2012,20,10:09:24
    2,11/28/2012,20,10:09:24
    2,11/28/2012,20,10:09:25
    2,11/28/2012,20,10:09:25
    2,11/28/2012,20,10:09:26
    3,11/28/2012,20,10:09:34
    3,11/28/2012,20,10:09:34"""
    #after testing replace io.StringIO(temp) to filename
    df = pd.read_csv(io.StringIO(temp), parse_dates=[['Date','Time']])
    
    
    print (df)
                Date_Time  GIdx  num
    0 2012-11-28 10:05:50     1   20
    1 2012-11-28 10:05:50     1   20
    2 2012-11-28 10:09:24     2   20
    3 2012-11-28 10:09:24     2   20
    4 2012-11-28 10:09:25     2   20
    5 2012-11-28 10:09:25     2   20
    6 2012-11-28 10:09:26     2   20
    7 2012-11-28 10:09:34     3   20
    8 2012-11-28 10:09:34     3   20
    
    print (df.dtypes)
    Date_Time    datetime64[ns]
    GIdx                  int64
    num                   int64
    dtype: object
    

You can omit parameters `sep=","`, `header = 0` and `na_values=['NA']`,
because there are by default:

    
    
    df=pd.read_csv(filename,sep=",", header = 0, na_values=['NA'])
    
    
    df=pd.read_csv(filename)
    

