Pandas: Extract the day name from a specified date
Pandas Time Series: Exercise-25 with Solution
Write a Pandas program to extract the day name from a specified date. Add 2 days and 1 business day with the specified date.
Python Code :
import pandas as pd newday = pd.Timestamp('2020-02-07') print("First date:") print(newday) print("\nThe day name of the said date:") print(newday.day_name()) print("\nAdd 2 days with the said date:") newday1 = newday + pd.Timedelta('2 day') print(newday1.day_name()) print("\nNext business day:") nbday = newday + pd.offsets.BDay() print(nbday.day_name())
First date: 2020-02-07 00:00:00 The day name of the said date: Friday Add 2 days with the said date: Sunday Next business day: Monday
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Pandas program to generate time series combining day and intraday offsets intervals.
Next: Write a Pandas program to convert integer or float epoch times to Timestamp and DatetimeIndex.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
>>> "Python ROCK" if True else " I AM GRUMPY" "Python ROCK"
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework