Pandas Datetime: Create the todays date
1. Current Date
Write a Pandas program to create the todays date.
Sample Solution :
Python Code :
import pandas as pd
from datetime import date
now = pd.to_datetime(str(date.today()), format='%Y-%m-%d')
print("Today's date:")
print(now)
Sample Output:
Today's date: 2019-07-08 00:00:00
For more Practice: Solve these Related Problems:
- Write a Pandas program to create a DataFrame containing only today’s date using datetime.today() and display it.
- Write a Pandas program to insert today’s date into a new column of an existing DataFrame and print the updated DataFrame.
- Write a Pandas program to create a Series with today's date repeated 10 times and verify its data type.
- Write a Pandas program to compare today’s date with a fixed historical date and display the result as a boolean Series.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Python Pandas Datetime Home.
Next: Write a Pandas program to calculate all the sighting days of the unidentified flying object (ufo) from current date.
What is the difficulty level of this exercise?