I have a very large panda data frame with rows for every ten minutes of the year. One column of the dataframe has the name 'quarter' and is 1 for Jan - March, 2 for April to June, 3 for July Oktober etc... Now I want to add a certain amount of values into another column, but only if its in the first quarter and I want to add them randomly.
This is the closest I got:
dfupdate=test_df.sample(5000)
dfupdate.status='TEST'
test_df.update(dfupdate)
But it will divide the 5000 entrys into the whole year while I only want them in the first quarter.
Basically I need an algorithm that adds a certain amount of values to one column to all the raws where another column has the value one.
In the next step I would like to change the following rows of row with a certain value. So if the value I added in the first step ('TEST') is found, it should add it to the next x rows.
I hope you understand my problem and I'd be really thankful if somebody could help me out.
Best wishes,
Elias
Aucun commentaire:
Enregistrer un commentaire