Reputation: 43
I have a column with the weekday, another with the month and another with the year. How do I get the actual date in python?
Upvotes: 1
Views: 222
Reputation: 882
import pandas as pd
df = pd.DataFrame({"year": [2018], "month": [12], "day": [1]})
df["date"] = pd.to_datetime(df[["year", "month", "day"]]).dt.date
print(df)
# year month day date
# 0 2018 12 1 2018-12-01
Upvotes: 2
Reputation: 109
from datetime import date
print(date.today())
This should work!
Upvotes: 0
Reputation: 36
You can use the datetime library:
import datetime
x = datetime.datetime(year, month, day)
print(x)
Documentation: https://docs.python.org/3/library/datetime.html
Upvotes: 0