How to find the first Monday of a given month using NumPy? Last Updated : 02 Dec, 2020 Comments Improve Suggest changes Like Article Like Report To find the first Monday of a given month, we are going to use the numpy module i.e the numpy.busday_offset() method in numpy module. Syntax: np.busday_offset('date', 0, roll='forward', weekmask='Mon') Parameters: date: The array of dates to process. offsets: The array of offsets, which is broadcast with dates. roll:It takes the below values: raise means to raise an exception for an invalid day.nat means to return a NaT (not-a-time) for an invalid day.forward and following mean to take the first valid day later in time.backward and preceding mean to take the first valid day earlier in time.modifiedfollowing means to take the first valid day later in time unless it is across a Month boundary, in which case to take the first valid day earlier in time.modifiedpreceding means to take the first valid day earlier in time unless it is across a Month boundary, in which case to take the first valid day later in time. weekmask: array indicating which of Monday through Sunday are valid days. Returns (outarray of datetime64): An array with a shape from broadcasting dates and offsets together, containing the dates with offsets applied. Below are some programs which use numpy.busday_offset() method to get first Monday of a month: Example #1: In this example, we will find the first Monday of the month of May 2017. Python3 # import module import numpy # input year and month yearMonth = '2017-05' # getting date of first monday date = numpy.busday_offset(yearMonth, 0, roll='forward', weekmask='Mon') # display date print(date) Output: 2017-05-01 Example #2: Here, we will find the first Monday of the month of February 2001. Python3 # import module import numpy # input year and month yearMonth = '2001-02' # getting date of first monday date = numpy.busday_offset(yearMonth, 0, roll='forward', weekmask='Mon') # display date print(date) Output: 2001-02-05 Example #3: Here, we will find the first Monday of the month of November 2020. Python3 # import module import numpy # input year and month yearMonth = '2020-11' # getting date of first monday date = numpy.busday_offset(yearMonth, 0, roll='forward', weekmask='Mon') # display date print(date) Output: 2001-11-02 Comment More infoAdvertise with us Next Article How to find the first Monday of a given month using NumPy? H hitainkakkar007 Follow Improve Article Tags : Python Python-numpy Python numpy-DataType Practice Tags : python Similar Reads Find the number of weekdays of a given month using NumPy In NumPy we can find the number of weekdays in a given month with the help of busday_count() In this pass the given month is the first parameter and next month as the second parameter. It will return the total number of weekdays in a given month. Syntax: numpy.busday_count(begindates, enddates, week 1 min read Count the number of days of a specific month using NumPy In order to count the number of days of a specific month, we will be using numpy.datetime64() method of numpy module. Examples: Input: month = 2; year = 2016 Output: 29 days Input: month = 12; year = 2020 Output: 31 days Let us assume the month whose number of days we want to count be P and the next 3 min read Display all the dates for a particular month using NumPy In NumPy to display all the dates for a particular month, we can do it with the help of NumPy.arrange() pass the first parameter the particular month and the second parameter the next month and the third parameter is the datatype datetime64[D]. It will return all the dates for the particular month. 1 min read Display all the Sundays of given year using Pandas in Python Let's see how to display all the Sundays of a given year using Pandas. We will be using the date_range() function of the Pandas module. Algorithm : Import the pandas module. Fetch all the Sundays using the date_range() function, the parameters are : In order to display Sundays of 2020, start paramet 3 min read Get the dates of Yesterday, Today, and Tomorrow using NumPy In NumPy with the help of NumPy.datetime64('today', 'D'), we will find today date and if we want some date before today then we will subtract the no-of-date with the help of np.timedelta64() from today. And if we want some date after today then we will add the no of date with the help of np.timedelt 1 min read Python calendar module : prmonth() method The calendar module allows the output of calendar-like programs and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar is extended indefinitely in both directions. class calendar.Tex 2 min read How to Find Day Name from Date in Python In Python programming, we may frequently need to know which day of the week corresponds to a particular date. This can be useful for a variety of applications, including task scheduling, trend analysis, and showing dates in an easy-to-read style.Get Day Name from Date in PythonTo get the day name fr 3 min read How to display the days of the week for a particular year using Pandas? Given the day and the year. The task is to display all the days of the week of the given year. It can be found using the pandas.date_range() function. This function is used to get a fixed frequency DatetimeIndex. Syntax: pandas.date_range(start=None, end=None, periods=None, freq=None, tz=None, norma 2 min read Python calendar module | firstweekday() method Calendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. In Python, calendar.firstwee 2 min read SQL Query to Get First and Last Day of a Month in a Database In SQL, working with date and time data is critical for tasks like reporting, scheduling, and data analysis. Determining the first and last day of a month is a common requirement. SQL provides powerful functions like DATE_SUB, DAYOFMONTH, and LAST_DAY to make these calculations straightforward.In th 4 min read Like