I have a dictionary with lists as values as you can see here:
my_dict = {1: ['Home', 'Stories'], 2: ['Sounds', 'Stories', 'Home', 'Home', 'Stories'], 3: ['Journeys / Series', 'Journeys / Series', 'Journeys / Series'], 4: [ 'Home', 'Home', 'Home'], 5: ['Home', 'Stories', 'Home', 'Home', 'Home', 'Cancellation Flow'], 6: ['My Account', 'My Account']}
I would like to turn the lists within these dictionaries into string and append them into their own column.
This is what I tried so far, but it does not work as the values in the dictionary are lists.
keys_list = list(my_dict.keys())
values_list = list(my_dict.values())
df_keyvalues = pd.DataFrame({'Column1': keys_list, 'Column2': values_list})
df_keyvalues
I would like my output to look like this:
User List
1 'Home', 'Stories'
2 'Sounds', 'Stories', 'Home', 'Home', 'Stories'
3 'Journeys / Series', 'Journeys / Series', 'Journeys / Series'
4 'Home', 'Home', 'Home'
5 'Home', 'Stories', 'Home', 'Home', 'Home', 'Cancellation Flow'
6 'My Account', 'My Account'
With
delimiter.join(list)you can join your lists as a string:Is this what your are looking for?