I have been going in circles with this question. I am writing a simple Python script in Power BI. I am trying to load a Dataframe and change a particular person's Department in a column based on a conditional column, i.e. if they have a Yes, then the department will change for them for the data. I could really use some feedback as to how I could change the syntax and if my code is correct. Specifically, I am getting a syntax error on the name of the Last Name column. This is what I have:
import pandas as pd
final = pd.DataFrame(dataset.loc[:,'Department','Last Name','Employee Promotion'])
for i in pd.final:
if i in pd.final.loc['Last Name'] = "Carter" and in pd.final.loc['Employee Promotion'] = True:
new_department = "Admin"
pd.final(dataset.loc[:,'Department') = new_department
pass
ifelse i in pd.final.loc['Last Name'] = "Litwack" and in pd.final.loc['Employee Promotion'] = True:
new_department1 = "OAAS"
pd.final(dataset.loc['Department') = new_department1
else pd.final.loc['Department']