-1
Based on csv year columns, Month, day, hour, minute how to add to a single column?
df['date'] = pd.to_datetime(
-1
Based on csv year columns, Month, day, hour, minute how to add to a single column?
df['date'] = pd.to_datetime(
0
df = pd.DataFrame([{'Year': 2015, 'Month': 5,'Day': 11, 'Hour': 11, 'Minute': 45},
                  {'Year': 2016, 'Month': 11,'Day': 21, 'Hour': 23, 'Minute': 15}])
lst = []
for i in range(len(df)):
    x = str(df.iloc[i]['Month']) + '/' + str(df.iloc[i]['Day']) + '/' + str(df.iloc[i]['Year']) + " " + str(df.iloc[i]['Hour']) + str(df.iloc[i]['Minute'])
    lst.append(x)
for dates in lst:
    df['date'] = pd.Timestamp(dates)
df
Output:
    Day Hour    Minute  Month   Year    date
0   11  11  45  5   2015    2016-11-21 23:15:00
1   21  23  15  11  2016    2016-11-21 23:15:00
Browser other questions tagged python pandas
You are not signed in. Login or sign up in order to post.
or with this list comprehension: lst = [str(df.iloc[i]['Month']) + '/' + str(df.iloc[i]['Day']) + '/' + str(df.iloc[i]['Year']) + " + str(df.iloc[i]['Hour']) + str(df.iloc[i]['Minute']) for i in range(Len(df(df.iloc]))]
– Fabrício Patrocínio