- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print the days in a given month using Python?
Input −
Assume, you have date series to find the number of days in a month.
Solution
To solve this, we will follow the steps given below −
Define date series
Set date_range value as 2020-02-10.
find the number of days in a month using Series.dt.daysinmonth
Example
Let us see the complete implementation to get a better understanding −
import pandas as pd date = pd.date_range('2020-02-10',periods=1) data = pd.Series(date) print(data.dt.daysinmonth)
Output
0 29
Advertisements