I am very new to python environment.
I am trying to replicate one of the SAS code in python.
I want to create 3 columns based on multiple conditions:
Below are the requirements:
if year is 2019 i want to create a column as en2019 and assign value as 1 else assign value as 0
same goes for year 2020.
Another condition is
if year=comm_year (2019=2019) then create a column 'commencing'and assign value as 'commencing' else assign value as 'Re-Enrolling'.
For your reference, I have attached the word document of SAS function and output which I am trying to replicate it in python.
Below is the data frame:
Expand|Select|Wrap|Line Numbers
- data = {'year': [2019, 2020, 2019, 2020, 2019],
- 'comm_year': [2019, 2019, 2020, 2020, 2019],
- 'count':[1,1,1,1,1]}
- enrol = pd.DataFrame(data, columns = ['year','comm_year','count'])
- enrol
Thanks.