Skip to content
Advertisement

Adding data based on date from another dataframe

I have two datasets. One with multiple dates:

JavaScript

and one with sunrise and sunsets data:

JavaScript

I want to add a column to the first dataframe with either “Day” or “night”, based on whether the date and time from the first dataframe is between the sunrise and sunset time and dates.

JavaScript

I tried copying and if_else functions, but the length of rows is different because for one year I have 365 sunrises and sunsets but I’ve also got multiple measurements for one day (total of 28000 rows).

Can anyone help me with my problem. Thanks in advance.

Advertisement

Answer

JavaScript
Advertisement