0
I have these lists:
data_list_com_todos_os_dados = [x for x in queryset_data if x not in data_list_all]
data_list_ que conta_repetições = { y:data_list_3.count(y) for y in set(data_list_3)}
that returns me this result:
{'2019-06-08': 2, '2019-06-06': 2, '2019-06-10': 2, '2019-06-03': 1, '2019-06-02': 2, '2019-06-04': 1}
is the result I was hoping for.
I’m using python3 and django2 to create graphs, but I’m having a hard time getting only the value of the items to put them in another or the same list keeping the positions, because then JSON can render the data and generate the graph.
I think the list I created has 3 positions: [index,valor:quantidade_de_vezes_que_se_repete]
and I’m not getting just the quantidade_de_vezes_que_se_repete
. I read and researched a little but I could not resolve my doubt.
I understand, thank you very much, I will give one more read on dicionario and list because I was complicated with that I swear that I was putting up lists and not dics thank you very much. and I will seedlings to dics all because readability is very important in the code, an avez que Sta getting giant the code.
– MARCELO PEREIRA DA SILVA
One thing I think worth commenting on too: unless you have absolute certainty that you will not have more than one die on the same date, avoid using them as keys, as these are unique. That is, if you use dates as keys in a dictionary and have more than one data at some date, you will end up losing this data.
– Murilo Sitonio
@Murilositonium Well observed, but in this case it seems not to take this risk since the stored value is precisely the amount of times that the date was repeated in the original structure.
– Woss