0

I have data for 2 years and want to change each day in an automated way like :

for year in set(df.index.year):
    for day in set(df[df.index.year == year].index.dayofyear):
        df[df.index.year == year][df.index.dayofyear == day] = 2

The strange thing is that setting new values doesn't work at all. So I use 2 filters at once. The selection works. But changing the value doesn't work. Does someone share the same problem? Are there other ways to do so?

Paul Z
  • 11
  • 1
  • 2
    Can you add sample of data and desired output? Maybe help [How to make good reproducible pandas examples](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – jezrael Nov 16 '16 at 14:47
  • Why not `df.index.date == date` with a single loop? – Psidom Nov 16 '16 at 14:48
  • That is what I need, thank you! But yes, changing data with double filtering is not supported I think. so like e.g.: df[df.index.year == year][df.index.dayofyear == day] = 2 – Paul Z Nov 16 '16 at 15:12

0 Answers0