Ich bin neu bei Python und habe zahlreiche Seiten dafür angeschaut.Kartenliste von Wörterbüchern
weiß ich Pandas Datenrahmen haben diese Zuordnung functionlity:
dictionary = {a:1, b:2, c:6}
df['col_name'] = df.col_name.map(dictionary) #df is a pandas dictionary
Wie kann ich etwas tun ähnlich für Listen, dh
mapped_list = list_to_be_mapped.map(dictionary)
wo in
list_to_be_mapped = [a,a,b,c,c,a]
mapped_list = [1,1,2,6,6,1]
Sollte Ihre 'mapped_list' nach Ihrem Diktat '[1, 1, 2, 6, 6, 1] sein? –
Ja, ich habe die Änderungen implementiert. Es war ein kleiner Tippfehler. Dies ändert jedoch nicht die Antwort! Danke. –