Just started working in Python and ran into this error.
I have two data frames A and B. I use one of input columns to key on A and then combining both, I want to key on B. I am getting an error in the second print step. I did look at other similar threads but did not find a solution. Can you help me fix it?
import pandas as pd
A = pd.DataFrame([
{"AC1":"V1", "AC2":"190801"},
{"AC1":"V2", "AC2":"200414"},
])
A = A.set_index("AC1")
B = pd.DataFrame([
{"BC1":"V1","BC2":"190801","BC3":"2019-10-01"},
{"BC1":"V1","BC2":"191201","BC3":"2019-12-01"},
{"BC1":"V2","BC2":"200414","BC3":"2020-01-24"}
])
B["BC3"] = pd.to_datetime(B["BC3"])
B = B.set_index(["BC1","BC2"])
input = pd.DataFrame([
{"X":"V1","State":"FL","Z":100},
{"X":"V2","State":"CA","Z":130},
])
for item in input["X"].unique():
p1 = A.loc[item]
print(p1)
p2 = B.loc[[(item,p1)],"BC3"]
print(p2)
TypeError: 'Series' objects are mutable, thus they cannot be hashed