I am formatting a dictionary like so:
for index, team_id in dataframe.get('team_id').items():
format_redis[str(team_id)] = {
'x': float(dataframe['x'][index]),
'y': float(dataframe['y'][index]),
'z': float(dataframe['z'][index]),
'n': float(dataframe['n'][index])
}
Now I'd like to pass a condition for adding the value, like: ...
{'x': float(dataframe['x'][index]) if str(dataframe['home'][index] == 'home',
'y': float(dataframe['y'][index]) if str(dataframe['home'][index] == 'away'}
But this syntax is not valid. Which one is the right one?
Aucun commentaire:
Enregistrer un commentaire