【发布时间】:2021-09-22 04:20:04
【问题描述】:
您好,我希望从 python 字典列表中计算一些东西,其中数据如下所示。当 Name="TOM" 我想要城市、国家键和国家的计数。我想从下面的格式表中计算的文件在数据后明确提到,请查看并提出最佳的计算方法
people = [
{"name": "Tom", "age": 10, "city": "NewYork", "Date":2021-01-04 08:37:19Z},
{"name": "Mark", "age": 5, "country": "Japan", "Date": 2021-01-06 08:37:24Z},
{"name": "Pam", "age": 7, "city": "London", "Date": 2021-01-04 09:26:38Z},
{"name": "Tom", "hight": 163, "city": "California", "Date": 2021-01-08 12:50:17Z},
{"name": "Lena", "weight": 45, "country": "Italy", "Date": 2021-01-08 12:50:17Z},
{"name": "Ben", "age": 17, "city": "Colombo", "Date": 2021-01-21 09:56:04Z},
{"name": "Lena", "gender": "Female", "country": "Italy", "Date": 2021-01-21 09:56:04Z},
{"name": "Ben", "gender": "Male", "city": "Colombo", "Date": 2021-02-09 08:47:26Z},
{"name": "Tom", "age": 10, "country": "Italy", "Date": 2021-02-09 08:47:26Z},
{"name": "Mark", "age": 5, "country": "Japan", "Date": 2021-02-23 09:10:59Z},
{"name": "Tom", "age": 7, "city": "London", "Date": 2021-03-08 09:39:28Z},
{"name": "Tom", "hight": 163, "country": "Japan", "Date": 2021-03-08 09:39:28Z},
]
期望以下格式的输出,
姓名:12
汤姆:5
城市:3
时间线的数据计数,
城市:纽约
1 月 1 日、2 月 2 日、3 月 2 日
城市:伦敦
1 月 2 日、2 月 1 日、3 月 4 日
I have 1000s of these data in list of dictionaries format with lot of other parameters. I am new to this and can some please help getting this solved
【问题讨论】:
标签: python pandas list dictionary datetime