BTC-E ticker time format
Question: Im using python to pull the Bitcoin ticker into a pandas DF and put into my
SQL Database, however I have no idea what format the dam servertime and
updated times are in. I would like to convert the the time in my pandas DF
first then put into my SQL DB.

    
    
    import pandas as pd
    import urllib
    import json
    from pandas.io.json import json_normalize
    import sqlalchemy
    
    engine = sqlalchemy.create_engine("mssql+pyodbc://@localhost")
    
    bitcoin = 'https://btc-e.com/api/2/btc_usd/ticker'
    data = urllib.urlopen(bitcoin)
    data = json.load(data)
    data = json_normalize(data)
    
    data = pd.DataFrame(data)
    
    data.to_sql('TESTTABLE',engine, if_exists='append', index = False)
    
    print data
    

For now the servertime and updated information is going into columns in my SQL
DB that are set to bigint datatype.

Anyhelp would be awesome :)


Answer: Right now pandas is bringing both times in as int64. Changing them is
relatively easy with pd.to_datetime() once you figure out the format (sorry,
can't help you there). to_datetime() will change the data type and parse the
date based on the format parameter. For example

    
    
    data['ticker.server_time'] = pd.to_datetime(data['ticker.server_time'],
    format='whatever is needed')
    

format : string, default None strftime to parse time, eg "%d/%m/%Y", note that
"%f" will parse all the way up to nanoseconds

I tried using the infer_datetime_format parameter with that data, but it
didn't make a difference.

    
    
    data['ticker.server_time'] = pd.to_datetime(data['ticker.server_time'],
    infer_datetime_format=True)` 
    

