0
how to print items within a nested dictionary where values are of list
hi i tried to describe as best i could - so within a dictionary with lists as values how can i print side by side the correct indexes within each list while calling out each key- this is more of a how it works question i suppose https://code.sololearn.com/cdNfA32UeR9x/?ref=app
11 Antworten
+ 8
ren[paused] ,
to get the output as mentioned from you, we can use the zip() function to combine it like:
2021-06-10, 42.8
2021-06-11, 102.03
2021-06-12, 240.38
2021-06-13, 80.9
do a try with zip(), if you get stuck somewhere just post your attempt.
happy coding!
+ 2
Not sure what you mean, but look here
https://code.sololearn.com/cyfM8V4Dz7Nx/?ref=app
+ 1
Oh okay i gotcha. Pandas is good for this just because it's written in a way where everything is uniform. Using different data containers without the use of pandas just means you have to write specific code for whatever data set you're working with.
+ 1
gah i forgot bout that one 🤯
+ 1
i guess part of the idea is what do you do / best practice when you dont know entirely what oncoming data could be, but you need to build a container for it. that is what i think it feels like id be in for
+ 1
here is my attempt - https://code.sololearn.com/cuWfeYJY3Pew/?ref=app
+ 1
Nope! Lothar remembered a really useful one! As long as each list contains the same amount of values it doesnt matter how many keys you have. The zip method will stick each key[index] value into a tuple with the others of the same index. I forgot about that too haha
0
yea like that! i am learning pandas and i wondered how else could it be done - i didnt know how to phrase my question better
0
i kind of understand the basic idea for zip here? but when you dont know how many lists i guess you have to loop through them instead of statically input them like i just did :D
0
from previous (sounds like this could be a job for unpack operator?)
0
but do you need to resort to unpacking when it gets longer and you have
'a' : [0,1,2] , 'b : [1,3,10] , c : [0,8,9]
and like many of these