string-to-datetime

ValueError: time data 'r' does not match format '%Y%m%d:%H%M' (match)

ValueError: time data 'r' does not match format '%Y%m%d:%H%M' (match) Question: I am trying to read data from an online database and convert the first row to a timestamp. Although using the right format string in to_datetime, but I got the error time data ‘r’ does not match format ‘%Y%m%d:%H%M’ (match) Here is the code: …

Total answers: 1

Set the format for pd.to_datetime

Set the format for pd.to_datetime Question: Hi already referred to this post but I could not get through my issue. I have a column in my CSV which is string and the sample values are below (note that the month and year positioning are sometimes reversed). What format do I need to set in my …

Total answers: 3

Change dataframe column names from string format to datetime

Change dataframe column names from string format to datetime Question: I have a dataframe where the names of the columns are dates (Year-month) in the form of strings. How can I convert these names in datetime format? I tried doing this: new_cols = pd.to_datetime(df.columns) df = df[new_cols] but I get the error: KeyError: “DatetimeIndex( [‘2000-01-01’, …

Total answers: 2

Why is pandas.to_datetime slow for non standard time format such as '2014/12/31'

Why is pandas.to_datetime slow for non standard time format such as '2014/12/31' Question: I have a .csv file in such format timestmp, p 2014/12/31 00:31:01:9200, 0.7 2014/12/31 00:31:12:1700, 1.9 … and when read via pd.read_csv and convert the time str to datetime using pd.to_datetime, the performance drops dramatically. Here is a minimal example. import re …

Total answers: 3