I have a dataframe like so:
I would like to create a dictionary that looks like this:
dict = {'car' : ['mazda', 'toyota', 'ford'],
'bike' : ['honda', 'kawasaki', 'suzuki']
}
I have tried a number of answers found on stackoverflow, including this one: dict(df.values)
, that I found at Convert a Pandas DataFrame to a dictionary, but this gave me this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [38], line 1
----> 1 dict(df.values)
TypeError: 'dict' object is not callable
This is part of an assignment. The instructor left a hint in the assignment suggesting they are expecting a x for x in df
type solution.
Any help would be appreciated.