Jul-02-2017, 12:14 AM
Hi,
I am very new to python and decided to learn so I could automate my very time-consuming excel data analysis. I have managed to write a simple script to take care of most of my needs, but there is still one aspect that I can't figure out.
In my excel file, I have a column (Target Reward) that contains values (either 1, 0 or -1).
I need my script to determine the value of cell in the Target Reward column and create a column and add a 1 each time a 1 is followed by a 1 or a -1 in the Target Reward column and a 0 if not.
Here is an example dataframe
Trial Target Reward New Column
1_________ 1
2_________ 0 _________ 0
3_________ 1 _________ 0
4_________ 1_________ 1
5_________ 0 _________ 0
6_________ 1 _________ 0
7_________ -1 _________1
Does anyone have any idea how I can solve this problem?
Thanks!
I am very new to python and decided to learn so I could automate my very time-consuming excel data analysis. I have managed to write a simple script to take care of most of my needs, but there is still one aspect that I can't figure out.
In my excel file, I have a column (Target Reward) that contains values (either 1, 0 or -1).
I need my script to determine the value of cell in the Target Reward column and create a column and add a 1 each time a 1 is followed by a 1 or a -1 in the Target Reward column and a 0 if not.
Here is an example dataframe
Trial Target Reward New Column
1_________ 1
2_________ 0 _________ 0
3_________ 1 _________ 0
4_________ 1_________ 1
5_________ 0 _________ 0
6_________ 1 _________ 0
7_________ -1 _________1
Does anyone have any idea how I can solve this problem?
Thanks!
my code here