Ho un dataframe come questo:Trova il nome della colonna che ha il massimo valore per ogni riga
In [7]:
frame.head()
Out[7]:
Communications and Search Business General Lifestyle
0 0.745763 0.050847 0.118644 0.084746
0 0.333333 0.000000 0.583333 0.083333
0 0.617021 0.042553 0.297872 0.042553
0 0.435897 0.000000 0.410256 0.153846
0 0.358974 0.076923 0.410256 0.153846
Qui, voglio chiedere come ottenere nome della colonna che ha il massimo valore per ogni riga, l'uscita desiderata è così:
In [7]:
frame.head()
Out[7]:
Communications and Search Business General Lifestyle Max
0 0.745763 0.050847 0.118644 0.084746 Communications
0 0.333333 0.000000 0.583333 0.083333 Business
0 0.617021 0.042553 0.297872 0.042553 Communications
0 0.435897 0.000000 0.410256 0.153846 Communications
0 0.358974 0.076923 0.410256 0.153846 Business
Come posso ottenere la seconda massimo? Volevo le 3 migliori probabilità quindi ... –
@SushantKulkarni, Controlla la mia risposta di seguito –
@SushantKulkarni Come sei riuscito a ottenere le prime 3 probabilità anziché la prima posizione? – Stergios