Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

How to calculate no of day's present in month based on given date

sgnarkhede2016sgnarkhede2016 Member Posts: 152 Contributor II
I have the requirement of finding a total number of days in a month based on date. For e.g I have a date with me i.e. 15 April 2021 then a number of days must return 30 as April month consists of 30 days. If I have a date of 02 Feb 2020 then the number of days should return as 29 as it is a leap year.

Can we achieve this in RapidMiner using any in-built function or operator?

Best Answers

  • ceaperezceaperez Member Posts: 541 Unicorn
    Solution Accepted
    Hi @sgnarkhede2016,

    You can use the pandas.Period.days_in_month method in a python script. operator.
    p = pd.Period('2021-4-21')
    p.days_in_month
    return 30. 

    please find attached an example process 
  • Telcontar120Telcontar120 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 Unicorn
    Solution Accepted
    If you don't want to use python you can also extract the month from the date (using Generate Attributes) and then a lookup table to join the number of days based on the month.
    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts

Answers

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,529 RM Data Scientist
    well, isnt this just joining the days and taking care of february?

    Best,
    Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
Sign In or Register to comment.