lets say I have the string "df" and the dataframe
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('ab'))
I can print "df" with:
print("df")
And I can print my dataframe with:
print(df)
Which prints:
a b
0 1 2
1 3 4
Now why can't I do the following command?
print("df" + df)
I was expecting to get the output:
df
a b
0 1 2
1 3 4
But I get error messages instead.
print("df", df). You cannot concatenate astrand apandas.DataFrame. You could concatenatestr(df)orrepr(df)and a string.