I am trying to create a Pandas crosstab, but I then want to run a join and it won't let me since I think it's a special type of DataFrame. See below for an example.
df = pd.DataFrame({'A': ["Alice", "Alice", "Alice", "Bob","Bob","Bob","Charlie"], 'B': ["X","X","Y","X","Y","Z","Z"]})
z = pd.crosstab(df['A'],df['B'])
z.index.name="ID"
z.reset_index(inplace=True)
zz = pd.DataFrame({"ID":["Alice","Daniel","Bob","Charlie"})
zz.join(z,on="DT_ID")
And then I get the following error message:
ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat
However, if I check the dtypes, they are objects in both ID columns. Am I missing something here?