I have a dataframe with two columns that are:
- A
datetime
column with the following format%Y-%m-%d
- An
int
column
They represent a day and an hour.
I want to merge because then I want to give to prophet
so I need to convert to this format:
YYYY-MM-DD HH:MM:SS
I tried this way:
example={"date":["2018-04-18","2018-04-18","2018-04-18"],"alert_h":[4,17,23]}
df=pd.DataFrame(example)
df['date']=pd.to_datetime(df['date']) #I am converting str to datetime just for creating the example, I have already in the original df a datetime format
df.assign(date_h=pd.to_datetime(df[['date','alert_h']], format='%Y-%m-%d %h'))
I receive the following error message.
ValueError: to assemble mappings requires at least that [year, month, day] be specified: [day,month,year] is missing
I read these following questions:
- Value Error at least that year month day must be specified
- How to convert columns into one date time column in pandas
- Convert Pandas Column to DateTime
If this is a duplicate, feel free to close this question I will study any other link because I was not able to find a specific question to solve my issue.