- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 Riot Game 的 API 中提取数据并填充用于机器学习的数据帧,但是我在将数据被提取到我的数据帧的格式转换时遇到了困难。我的数据框中的每一行代表一个玩家玩的游戏。特定的“单位”数据是从 API 中提取的,示例字典语法如下:
{'name': 'DarkStar', 'num_units': 6, 'style': 3, 'tier_current': 3, 'tier_total': 4}
{'name': 'Infiltrator', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}
{'name': 'Protector', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}
我希望每个游戏都有 14 个左右的列,每个“名称”对应一个值 = 'num_units'。我从字典中提取只需要的数据到一个列表中以便于访问:
[('Chrono', 2), ('Cybernetic', 2), ('DarkStar', 1)]
我的问题是这样的:我如何编程以便每个列都填充其相应的“num_units”(包括在游戏期间未使用特征类型的零)?例如,假设这三种特质类型是游戏中唯一使用的类型,“Chrono”、“Cybernetic”和“DarkStar”将各自具有相应的 num_units,其余 9 个特质将具有“0”。我的代码如下,任何帮助表示赞赏,因为我对此仍然很陌生。
placements = []
total_damage_dealt = []
trait_names = []
unit_values = []
rounds_lasted = []
game_length = []
game_ids = []
for game in game_request:
game_ids.append(game)
total_game_data = requests.get("https://americas.api.riotgames.com/tft/match/v1/matches/"+game+"?api_key=hidden")
total_game_data = total_game_data.json()
all_player_game_data = total_game_data['info']
length = all_player_game_data['game_length']
game_length.append(length)
participants = all_player_game_data['participants']
for participant in participants: #checks to see if user in list = target user
if participant['puuid'] == puuid:
unit_names = []
unit_qtys = []
placements.append(participant['placement'])
rounds_lasted.append(participant['last_round'])
total_damage_dealt.append(participant['total_damage_to_players'])
traits = participant['traits']
for i in range(len(traits)):
unit = traits[i]
unit_names.append(unit.get('name'))
unit_qtys.append(unit.get('num_units'))
trait_total = list(zip(unit_names, unit_qtys))
else:
pass
编辑
['NA1_3568227867']
total_game_data:
{'metadata': {'data_version': '4', 'match_id': 'NA1_3568227867', 'participants': ['6QdjrJ8Z2luRZ9anj_NaKaSJaHujCbQiCxM4Y8EOzU-0xWjS0ffhkBy4loBnTUu12c2J8V8edn_-AQ', 'o8ONYFnjauBocvolDOXiquZ0zI90XjbWRJbA5Ts9nVtQvea9iptxTswB7seKAco_u5pHYnlmmCvx-g', 'aoD-yE0c5DNFvqU51clI1NdcXe5_ioi89BRjJw_TMG0bcEaEUGZbyQygAl7pEk-_MxnbaoQ6e8fD-A', 'RjbYAkqkK92DkFYzBQdYipzR2Uic10Qrhu14eG9OqZW69ggqt-Q1RtaEmaXsQ04vcwxDpDBJHuzg9A', 'cG9lhyIaoZVZRl7AYEJzQ97G9wJ2Bm-PQRQB-_dfTX517RxlKij6ReyK5bioz-X2G2iCyd7gXzz0Pw', 'TZ19msUDNNwVr546B1PVy2yk_L1inWFkxydk0D4LHuer1aIlkQ6kGVg5sM_KVpVrDTF_v7TLVIMXeQ', 'TinjbjLvUe8SrzQuY8IWvK2mbGTia6KJQ1ZEylh12qNJsaT219Wlmf6KR5Y7RoTGN2DIbkvhCNLW5g', 'YMVx6f0CLfETeWRm7QwlXOkuroLZkaWKLZBMJLEL_TiFFInhsdTJtuZ9XUtPgIWRcDy23DHDW1O10Q']}, 'info': {'game_datetime': 1599630619849, 'game_length': 2259.0498046875, 'game_variation': 'TFT3_GameVariation_Finale', 'game_version': 'Version 10.18.333.8889 (Aug 31 2020/10:45:08) [PUBLIC] <Releases/10.18>', 'participants': [{'companion': {'content_ID': 'b93f1ae5-97b0-4194-bc0a-f212c7120543', 'skin_ID': 13, 'species': 'PetSGPig'}, 'gold_left': 1, 'last_round': 31, 'level': 8, 'placement': 4, 'players_eliminated': 0, 'puuid': '6QdjrJ8Z2luRZ9anj_NaKaSJaHujCbQiCxM4Y8EOzU-0xWjS0ffhkBy4loBnTUu12c2J8V8edn_-AQ', 'time_eliminated': 1785.7803955078125, 'total_damage_to_players': 79, 'traits': [{'name': 'Blaster', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}, {'name': 'Chrono', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total':
4}, {'name': 'DarkStar', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'Demolitionist', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'ManaReaver', 'num_units': 2, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Paragon', 'num_units': 1, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Rebel', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'SpacePirate', 'num_units': 3, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'StarGuardian', 'num_units': 2, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Vanguard', 'num_units': 4, 'style': 2, 'tier_current': 2, 'tier_total': 3}], 'units': [{'character_id': 'TFT3_Ziggs', 'items': [], 'name': '', 'rarity': 0, 'tier': 3}, {'character_id': 'TFT3_Graves', 'items': [26, 57], 'name': '', 'rarity': 0, 'tier': 3}, {'character_id': 'TFT3_Poppy', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Darius', 'items': [33, 39, 15], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Mordekaiser', 'items': [99, 37, 36], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Jayce', 'items': [67], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_WuKong', 'items': [59], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Thresh', 'items': [44], 'name': '', 'rarity': 4, 'tier': 2}, {'character_id': 'TFT3_Janna', 'items': [], 'name': '', 'rarity': 4, 'tier': 1}]}, {'companion':
{'content_ID': '9f756223-fe56-4ea1-9221-f5011bad94fe', 'skin_ID': 22, 'species': 'PetGriffin'}, 'gold_left': 2, 'last_round': 23, 'level': 7, 'placement': 7, 'players_eliminated': 0, 'puuid': 'o8ONYFnjauBocvolDOXiquZ0zI90XjbWRJbA5Ts9nVtQvea9iptxTswB7seKAco_u5pHYnlmmCvx-g', 'time_eliminated': 1324.1546630859375, 'total_damage_to_players': 29, 'traits': [{'name': 'Astro', 'num_units': 3, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Chrono', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'DarkStar', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'Rebel', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Set3_Brawler', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Set3_Celestial', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Set3_Mystic', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}, {'name': 'Sniper', 'num_units': 3, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'StarGuardian', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Vanguard', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}], 'units': [{'character_id':
'TFT3_Malphite', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Caitlyn', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Poppy', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Nautilus', 'items': [88], 'name': '', 'rarity': 1, 'tier': 1}, {'character_id': 'TFT3_Ashe', 'items': [14], 'name': '', 'rarity': 2, 'tier': 1}, {'character_id': 'TFT3_Karma', 'items': [], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Gnar', 'items': [], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Teemo', 'items': [37, 4], 'name': '', 'rarity': 3, 'tier': 1}]}, {'companion': {'content_ID': '6dcdc951-4e4b-4a24-876a-02c964f72b70', 'skin_ID': 13, 'species': 'PetFairy'}, 'gold_left': 1, 'last_round': 31, 'level': 7, 'placement': 5, 'players_eliminated': 0, 'puuid': 'aoD-yE0c5DNFvqU51clI1NdcXe5_ioi89BRjJw_TMG0bcEaEUGZbyQygAl7pEk-_MxnbaoQ6e8fD-A', 'time_eliminated': 1785.7803955078125, 'total_damage_to_players':
88, 'traits': [{'name': 'Astro', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'Chrono', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'DarkStar', 'num_units': 2, 'style': 1, 'tier_current': 1,
'tier_total': 4}, {'name': 'ManaReaver', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'Protector', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}, {'name': 'Set3_Celestial', 'num_units': 3, 'style': 1, 'tier_current': 1, 'tier_total': 3}, {'name': 'Sniper', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'SpacePirate', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Vanguard', 'num_units': 4, 'style': 2, 'tier_current': 2, 'tier_total': 3}], 'units': [{'character_id': 'TFT3_Darius', 'items': [33, 15], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Rakan', 'items': [], 'name': '', 'rarity': 1, 'tier': 3}, {'character_id': 'TFT3_XinZhao', 'items': [66, 15], 'name': '', 'rarity': 1, 'tier': 3}, {'character_id': 'TFT3_Mordekaiser', 'items': [], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Nautilus', 'items': [88], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Jayce', 'items': [6], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Ashe', 'items': [4], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Jhin', 'items': [29, 19, 5], 'name': '', 'rarity': 3, 'tier': 1}, {'character_id': 'TFT3_WuKong', 'items': [88, 77], 'name': '', 'rarity': 3, 'tier': 1}]}, {'companion': {'content_ID': 'e05960be-0add-4aa6-842d-1be017e7dd81', 'skin_ID': 16, 'species': 'PetSGShisa'}, 'gold_left': 0, 'last_round': 35, 'level': 7, 'placement': 3,
'players_eliminated': 2, 'puuid': 'RjbYAkqkK92DkFYzBQdYipzR2Uic10Qrhu14eG9OqZW69ggqt-Q1RtaEmaXsQ04vcwxDpDBJHuzg9A', 'time_eliminated': 2011.732666015625, 'total_damage_to_players': 108, 'traits': [{'name': 'Astro', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'Battlecast', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'DarkStar', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'Demolitionist', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'Infiltrator', 'num_units': 5, 'style': 3, 'tier_current': 2, 'tier_total': 3}, {'name': 'MechPilot', 'num_units': 3, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Rebel', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Set3_Sorcerer', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Sniper', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}], 'units': [{'character_id': 'TFT3_Nocturne', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Annie', 'items': [], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Annie', 'items': [], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Zed', 'items': [], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Shaco', 'items': [99, 4, 14], 'name': '', 'rarity': 2, 'tier': 3}, {'character_id': 'TFT3_Rumble', 'items': [25, 69, 77], 'name': '', 'rarity': 2, 'tier': 3}, {'character_id': 'TFT3_Fizz', 'items': [66, 44, 4], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Teemo', 'items': [28, 79, 33], 'name': '', 'rarity': 3, 'tier': 2}]}, {'companion': {'content_ID': '270079d1-2d24-41c2-b6a1-34613304e16c', 'skin_ID': 7, 'species': 'PetGhosty'}, 'gold_left': 1, 'last_round': 40, 'level': 9, 'placement': 2, 'players_eliminated': 2, 'puuid': 'cG9lhyIaoZVZRl7AYEJzQ97G9wJ2Bm-PQRQB-_dfTX517RxlKij6ReyK5bioz-X2G2iCyd7gXzz0Pw', 'time_eliminated': 2250.813232421875, 'total_damage_to_players': 158, 'traits': [{'name': 'Blaster', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}, {'name': 'Chrono', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 4}, {'name': 'Demolitionist', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'ManaReaver', 'num_units': 2, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Mercenary', 'num_units': 1, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Rebel', 'num_units': 2, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Set3_Blademaster', 'num_units': 2, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Set3_Celestial', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3},
{'name': 'Sniper', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}, {'name': 'SpacePirate', 'num_units': 4, 'style': 3, 'tier_current': 2, 'tier_total': 2}, {'name': 'Starship', 'num_units': 1, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Vanguard', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}], 'units': [{'character_id': 'TFT3_Graves', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Xayah', 'items': [22, 12, 24], 'name':
'', 'rarity': 0, 'tier': 3}, {'character_id': 'TFT3_Darius', 'items': [36, 13, 34], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Jayce', 'items': [55], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_MasterYi', 'items': [99, 13, 49], 'name': '', 'rarity': 2, 'tier': 3}, {'character_id': 'TFT3_Ashe', 'items': [4], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_WuKong', 'items': [57, 13, 19], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Gangplank', 'items': [49], 'name': '', 'rarity': 4, 'tier': 1}, {'character_id': 'TFT3_AurelionSol', 'items': [], 'name': '', 'rarity': 4, 'tier': 2}, {'character_id': 'TFT3_Thresh', 'items': [24, 23, 14], 'name': '', 'rarity': 4, 'tier': 1}]}, {'companion': {'content_ID': '6054d70b-e401-4bec-b350-f26865700c77', 'skin_ID': 13, 'species': 'PetPenguKnight'}, 'gold_left': 33, 'last_round': 20, 'level': 6, 'placement': 8, 'players_eliminated': 0, 'puuid': 'TZ19msUDNNwVr546B1PVy2yk_L1inWFkxydk0D4LHuer1aIlkQ6kGVg5sM_KVpVrDTF_v7TLVIMXeQ', 'time_eliminated': 1139.9739990234375, 'total_damage_to_players': 12, 'traits': [{'name': 'Blaster', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}, {'name': 'Chrono', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 4}, {'name': 'Cybernetic', 'num_units': 5, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Set3_Blademaster', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Set3_Brawler', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 2}, {'name': 'Set3_Celestial', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Sniper', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Vanguard', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}], 'units': [{'character_id': 'TFT3_Fiora', 'items': [88], 'name': '', 'rarity': 0, 'tier': 3}, {'character_id': 'TFT3_Leona', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Lucian', 'items': [57], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Vi', 'items': [], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Ashe', 'items': [24, 56], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Vayne', 'items': [12, 12], 'name': '', 'rarity': 2, 'tier': 1}, {'character_id': 'TFT3_WuKong', 'items': [], 'name': '', 'rarity': 3, 'tier': 1}]}, {'companion': {'content_ID': 'b5cab758-7194-412a-8370-908b11c90e0a', 'skin_ID': 16, 'species': 'PetPenguKnight'}, 'gold_left': 9, 'last_round': 40, 'level': 9, 'placement': 1, 'players_eliminated': 1, 'puuid': 'TinjbjLvUe8SrzQuY8IWvK2mbGTia6KJQ1ZEylh12qNJsaT219Wlmf6KR5Y7RoTGN2DIbkvhCNLW5g', 'time_eliminated': 2250.813232421875, 'total_damage_to_players': 234, 'traits': [{'name': 'DarkStar', 'num_units': 6, 'style': 3, 'tier_current': 3, 'tier_total': 4}, {'name': 'Infiltrator', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}, {'name': 'MechPilot', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'Protector', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}, {'name': 'Set3_Celestial', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}, {'name': 'Set3_Mystic', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Set3_Sorcerer', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Sniper', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'StarGuardian', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Vanguard', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}], 'units': [{'character_id': 'TFT3_JarvanIV', 'items': [36, 77], 'name': '', 'rarity':
0, 'tier': 2}, {'character_id': 'TFT3_Rakan', 'items': [39, 34, 69], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Mordekaiser', 'items': [], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Shaco', 'items': [16, 15, 22], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Ashe', 'items': [14, 16], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Karma', 'items': [], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Soraka', 'items': [], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Jhin', 'items': [29, 19], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Fizz', 'items': [34], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_Xerath', 'items': [], 'name': '', 'rarity': 4, 'tier': 1}]}, {'companion': {'content_ID': '52ed5723-d887-4e7e-b08a-405ec77a7878', 'skin_ID': 13, 'species': 'PetSGShisa'}, 'gold_left': 3, 'last_round': 27, 'level': 8, 'placement': 6, 'players_eliminated': 1, 'puuid': 'YMVx6f0CLfETeWRm7QwlXOkuroLZkaWKLZBMJLEL_TiFFInhsdTJtuZ9XUtPgIWRcDy23DHDW1O10Q', 'time_eliminated': 1559.3280029296875, 'total_damage_to_players': 40, 'traits': [{'name': 'Blaster', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Chrono', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 4}, {'name': 'Demolitionist', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 1}, {'name': 'ManaReaver', 'num_units': 2, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Protector', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'Rebel', 'num_units': 3, 'style': 1, 'tier_current': 1, 'tier_total': 3}, {'name': 'Set3_Celestial', 'num_units': 1, 'style': 0, 'tier_current': 0, 'tier_total': 3}, {'name': 'SpacePirate', 'num_units': 3, 'style': 1, 'tier_current': 1, 'tier_total': 2}, {'name': 'Starship', 'num_units': 1, 'style': 3, 'tier_current': 1, 'tier_total': 1}, {'name': 'Vanguard', 'num_units': 2, 'style': 1, 'tier_current': 1, 'tier_total': 3}], 'units': [{'character_id': 'TFT3_Ziggs', 'items': [], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Graves', 'items': [88], 'name': '', 'rarity': 0, 'tier': 2}, {'character_id': 'TFT3_Darius', 'items': [], 'name': '', 'rarity': 1, 'tier': 1}, {'character_id': 'TFT3_Rakan', 'items': [13, 15, 77], 'name': '', 'rarity': 1, 'tier': 2}, {'character_id': 'TFT3_Jayce', 'items': [], 'name': '', 'rarity': 2, 'tier': 2}, {'character_id': 'TFT3_Jinx', 'items': [11],
'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_WuKong', 'items': [], 'name': '', 'rarity': 3, 'tier': 2}, {'character_id': 'TFT3_AurelionSol', 'items': [36, 44, 5], 'name': '', 'rarity': 4, 'tier': 1}, {'character_id': 'TFT3_Thresh', 'items': [], 'name': '', 'rarity': 4, 'tier': 2}]}], 'queue_id': 1100, 'tft_set_number': 3}}
最佳答案
import requests
import pandas as pd
matchId = "NA1_3568227867"
puuid = "zzAlAUx53ZNbKaNaNjj2oiGNyEfdzYxIShbXm3KG5674sI10j1mzgCFNDeXT8weVKpPxmL9tcyibAA"
response = requests.get(f"https://americas.api.riotgames.com/tft/match/v1/matches/{matchId}", headers = {"X-Riot-Token" : "API-KEY"})
data = response.json()
participants = data["info"]["participants"]
# Create a list for every column in your dataframe
name = []
num_units = []
style = []
tier_current = []
tier_total = []
for participant in participants:
if (participant["puuid"] == puuid):
traits = participant["traits"]
for trait in traits:
name.append(trait["name"])
num_units.append(trait["num_units"])
style.append(trait["style"])
tier_current.append(trait["tier_current"])
tier_total.append(trait["tier_total"])
dataframe = pd.DataFrame(data={'name' : name, 'num_units' : num_units, 'style' : style, 'tier_current' : tier_current, 'tier_total' : tier_total})
print(dataframe)
关于python - 我需要帮助将列表转换为 Pandas 数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63803901/
我正在尝试将一个字符串逐个字符地复制到另一个字符串中。目的不是复制整个字符串,而是复制其中的一部分(我稍后会为此做一些条件......) 但我不知道如何使用迭代器。 你能帮帮我吗? std::stri
我想将 void 指针转换为结构引用。 结构的最小示例: #include "Interface.h" class Foo { public: Foo() : mAddress((uint
这有点烦人:我有一个 div,它从窗口的左上角开始过渡,即使它位于文档的其他任何位置。我试过 usign -webkit-transform-origin 但没有成功,也许我用错了。有人可以帮助我吗?
假设,如果将 CSS3 转换/转换/动画分配给 DOM 元素,我是否可以检测到该过程的状态? 我想这样做的原因是因为我正在寻找类似过渡链的东西,例如,在前一个过渡之后运行一个过渡。 最佳答案 我在 h
最近我遇到了“不稳定”屏幕,这很可能是由 CSS 转换引起的。事实上,它只发生在 Chrome 浏览器 上(可能还有 Safari,因为一些人也报告了它)。知道如何让它看起来光滑吗?此外,您可能会注意
我正在开发一个简单的 slider ,它使用 CSS 过渡来为幻灯片设置动画。我用一些基本样式和一些 javascript 创建了一支笔 here .注意:由于 Codepen 使用 Prefixfr
我正在使用以下代码返回 IList: public IList FindCodesByCountry(string country) { var query =
如何设计像这样的操作: 计算 转化 翻译 例如:从“EUR”转换为“CNY”金额“100”。 这是 /convert?from=EUR&to=CNY&amount=100 RESTful 吗? 最佳答
我使用 jquery 组合了一个图像滚动器,如下所示 function rotateImages(whichHolder, start) { var images = $('#' +which
如何使用 CSS (-moz-transform) 更改一个如下所示的 div: 最佳答案 你可以看看Mozilla Developer Center .甚至还有例子。 但是,在我看来,您的具体示例不
我需要帮助我正在尝试在选中和未选中的汉堡菜单上实现动画。我能够为菜单设置动画,但我不知道如何在转换为 0 时为左菜单动画设置动画 &__menu { transform: translateX(
我正在为字典格式之间的转换而苦苦挣扎:我正在尝试将下面的项目数组转换为下面的结果数组。本质上是通过在项目第一个元素中查找重复项,然后仅在第一个参数不同时才将文件添加到结果集中。 var items:[
如果我有两个定义相同的结构,那么在它们之间进行转换的最佳方式是什么? struct A { int i; float f; }; struct B { int i; float f; }; void
我编写了一个 javascript 代码,可以将视口(viewport)从一个链接滑动到另一个链接。基本上一切正常,你怎么能在那里看到http://jsfiddle.net/DruwJ/8/ 我现在的
我需要将文件上传到 meteor ,对其进行一些图像处理(必要时进行图像转换,从图像生成缩略图),然后将其存储在外部图像存储服务器(s3)中。这应该尽可能快。 您对 nodejs 图像处理库有什么建议
刚开始接触KDB+,有一些问题很难从Q for Mortals中得到。 说,这里 http://code.kx.com/wiki/JB:QforMortals2/casting_and_enumera
我在这里的一个项目中使用 JSF 1.2 和 IceFaces 1.8。 我有一个页面,它基本上是一大堆浮点数字段的大编辑网格。这是通过 inputText 实现的页面上的字段指向具有原始值的值对象
ScnMatrix4 是一个 4x4 矩阵。我的问题是什么矩阵行对应于位置(ScnVector3),旋转(ScnVector4),比例(ScnVector3)。第 4 行是空的吗? 编辑: 我玩弄了
恐怕我是 Scala 新手: 我正在尝试根据一些简单的逻辑将 Map 转换为新 Map: val postVals = Map("test" -> "testing1", "test2" -> "te
输入: This is sample 1 This is sample 2 输出: ~COLOR~[Green]This is sample 1~COLOR~[Red]This is sam
我是一名优秀的程序员,十分优秀!