I'm trying to do some string manipulations with Pandas and I would deeply appreciate your help! Here's my problem: I loaded a list of words from a csv file into a pandas dataframe called df, so that it looks as follows (here, I created the df manually):
data = {'Keyword': ['Apple', 'Banana', 'Peach', 'Strawberry', 'Blueberry'], 'Kategory': ['A', 'A', 'A', 'B', 'B']}
df = pd.DataFrame(data)
Now what I would like to do is some string manipulation based on the following conditions shown below. The output of the string manipulation should be saved to a new column.
# new column to store the results
output = []
# set up the conditions
for Keyword in df:
if df[Kategory] == 'A':
output.append(Keyword + 'first choice')
print(Keyword + 'first choice')
else:
output.append(Keyword + 'second choice')
print(Keyword + 'second choice')
Thank you very much for your help!!