vendredi 3 avril 2015

Selecting columns from a pandas dataframe based on row conditions

I have a pandas dataframe


In [1]: df = DataFrame(np.random.randn(10, 4))


In [2]: df Out[2]: 0 1 2 3 0 0.469112 -0.282863 -1.509059 -1.135632 1 1.212112 -0.173215 0.119209 -1.044236 2 -0.861849 -2.104569 -0.494929 1.071804 3 0.721555 -0.706771 -1.039575 0.271860 4 -0.424972 0.567020 0.276232 -1.087401 5 -0.673690 0.113648 -1.478427 0.524988 6 0.404705 0.577046 -1.715002 -1.039268 7 -0.370647 -1.157892 -1.344312 0.844885 8 1.075770 -0.109050 1.643563 -1.469388 9 0.357021 -0.674600 -1.776904 -0.968914


Is there a way I can only select columns which have value>0 So in the above example, the desired output would only be all rows associated with column zero


Aucun commentaire:

Enregistrer un commentaire