Ciao Matteo, ----- Original Message ----- > Ciao a tutti... > Piccoli problemi con gli array numpy. > > Domanda 1: > come faccio a sapere l'indice di un elemento X? > es. > a=np.array([1,2,3,4,3,2,1]) > come faccio a sapere le posizioni in cui c'è l'elemento '2' ovvero 1 > e 5?
la prima che mi viene in mente è: positions, = where(a==2) > > Domanda 2: > come faccio a sapere il numero di occorrenze di X in un array? (per > le > liste c'è count) > es. > a=np.array([1,2,3,4,3,2,1]) > (tipo > a.count(2) -> 2 > a.conut(4) ->1) len(positions) > > grazie a tutti. > Ciao > Matteo Ciao gianfranco > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > > _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python