I've used the .loc all over some other code I did and it worked fine but I've been at this one for a couple of hours with no luck so far. My objective is to create and populate a column in a dataframe using two other dataframes everywhere a condition is met.
I read the post here and tried these snippets
df = df[~df.index.duplicated()]
df.reindex()
but it didn't seem to work.
What does `ValueError: cannot reindex from a duplicate axis` mean?
import pandas as pd
df2 = df2.append(df, sort=True)
condition = df2['Period'] == df2['projection_period_1']
df2.loc[condition, 'Projection'] =
df2['Projected_A'] / df2['Weekly_A']
I expect the output to populate df2['Projection'] with df2['Projected_A'] / df2['Weekly_A'] everywhere that the condition is met.
Instead I get "ValueError: cannot reindex from a duplicate axis"