0

I have this df that counts all the weekdays and all the weekends out 10 years. Only 240 rows in this df

I would like to pull the value in the 'count' column into another df that has 1.4 million rows based on the identical month and year.

Below is my code:

if (df['MONTH'] == count_10_years['MONTH']) & (df["YEAR"] == count_10_years['YEAR']):
    df['NUM_DAYS'] = count_10_years['count']

Here is the image that I would like to replace the NUM_DAYS with the count from the other df. This df has 1.4 million rows

Error: ValueError: Can only compare identically-labeled Series objects

  • Your code isn't attempting doing at all what you expect, because the first is a Boolean check (which will fail because it's ambiguous) then the assignment just tries to align on index, not matching. Regardless, you should use [merge](https://pandas.pydata.org/docs/reference/api/pandas.merge.html?highlight=merge#pandas.merge) to bring over the information, you can enforce the match by specifying the `on` parameter – ALollz Feb 28 '22 at 16:15

0 Answers0