I have df
technologies = {'Writer1': ['Spark', 'PySpark', 'Hadoop', 'Python'],
'Location1': ['LA', 'RIV', 'CHV', 'LA'],
'Area1': ['L', 'R', 'C', 'L'],
'Writer2': ['Spark', 'Dil', 'Chee', 'Python'],
'Location2': ['RIV', 'RIV', 'LA', 'RIV'],
'Area2': ['R', 'R', 'L', 'R'],}
df = pd.DataFrame(technologies)
I want to create a new Location column indexing location 1/2 but only taking locations in Area1/2 "R" and "C"
So I would want
technologies = {'Writer1': ['Spark', 'PySpark', 'Hadoop', 'Python'],
'Location1': ['LA', 'RIV', 'CHV', 'LA'],
'Area1': ['L', 'R', 'C', 'L'],
'Writer2': ['Spark', 'Dil', 'Chee', 'Python'],
'Location2': ['RIV', 'RIV', 'LA', 'RIV'],
'Area2': ['R', 'R', 'L', 'R'],
'Location3': ['RIV', 'RIV', 'CHV', 'RIV']}
Is this possible? I am stuck and can't think of what would work for so many requirements.
Any help appreciated Thank you ===EDIT Sorry I did not include vital detail. I would like the location to index with the Writer1/2. For example if I index PySpark with RIV, I also want Dil to index with RIV. The code should not bypass a Writer if they both are in RIV or CHV.