我有一个XML文件,我想将其加载到熊猫中,我尝试了其他XML文件,但是为此形状不清楚,每次抛出错误时,我都不会提出熊猫数据框需要。有什么建议么 -
from collections import Counter
from collections import OrderedDict
class LeagueTable:
def __init__(self, players):
self.standings = OrderedDict([(player, Counter()) for player in players])
def record_result(self, player, score):
self.standings[player]['games_played'] += 1
self.standings[player]['score'] += score
def player_rank(self, rank):
rankings = dict()
players = list(self.standings)
for player in players:
rankings[player]= self.standings[player]['score'] / self.standings[player]['games_played']
sorted_score= sorted(rankings.items(), key=lambda kv: kv[1],reverse=True)
print(sorted_score)
return (sorted_score[rank-1][0])
table = LeagueTable(['Mike', 'Chris', 'Arnold'])
table.record_result('Mike', 2)
table.record_result('Mike', 3)
table.record_result('Arnold', 5)
table.record_result('Chris', 5)
print(table.player_rank(1))
我正在使用下面的代码。
-<tweet id="591154373696323584">
Diga cuanto nos van a costar las
<sentiment polarity="N" entity="Partido_Popular" aspect="Economia">autovías</sentiment>
de sus amiguetes ¿4500 millones o más ? @EsperanzAguirre @PPopular
</tweet>
-<tweet id="591154532362670080">
@lhermoso_ @sanchezcastejon
<sentiment polarity="N" entity="Partido_Socialista_Obrero_Espanol" aspect="Propio_partido">#DobleMoral</sentiment>
Castilla antes que Aragón...
</tweet>
我一无所有。