Pandas: Check if a day is a business day (weekday) or not
Pandas Time Series: Exercise-14 with Solution
Write a Pandas program to check if a day is a business day (weekday) or not.
Python Code :
import pandas as pd def is_business_day(date): return bool(len(pd.bdate_range(date, date))) print("Check busines day or not?") print('2020-12-01: ',is_business_day('2020-12-01')) print('2020-12-06: ',is_business_day('2020-12-06')) print('2020-12-07: ',is_business_day('2020-12-07')) print('2020-12-08: ',is_business_day('2020-12-08'))
Check busines day or not? 2020-12-01: True 2020-12-06: False 2020-12-07: True 2020-12-08: True
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Pandas program to create a series of Timestamps from a DataFrame of integer or string columns. Also create a series of Timestamps using specified columns.
Next: Write a Pandas program to get a time series with the last working days of each month of a specific year.
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