0
votes

Sélectionnez la ligne qui sont Nan Dataframe Pandas

    0           1       
2   Ticket      Open Time   
3   5302684589  2020.06.17 01:32:13
...
4   5302717457  2020.06.17 03:11:57
5   NaN         0
6   Closed P/L: Closed P/L:
7   Ticket      Open Time
8   5302718245  2020.06.17 03:12:14
...
I have a database which I have loaded as dataframe by using pandas, I only need the first part data, namely for this example the rows from no.2  to no.4: we can use df.iloc[2:4] which is easy; \nHowever, I have many dataframe that the first part data is not from #2 to #4. \nLucikly, for all dataframe there is one line which is NaN in the first column, for this example, no.5 is NaN in the begining, so I want to identify which row is NaN and then I can know the index of the NaN rows that I can quickly select the first part data I want. \nmy question is how can I select the data I want by using the NaN row, others may also have this problem, so I post it here

1 commentaires

3 Réponses :


1
votes

Cela devrait vous donner le premier index de la ligne où toutes les entrées sont nan

df [df.isnull (). Tout (axe = 1)]. Index [0]

Vous pouvez maintenant faire le df.loc [0: df [df.isnull (). Tous (Axis = 1)]. Index [0],:]


0 commentaires


0
votes

df [df.iloc [:, 0] .isnull ()]. ​​Index [0] Peut résoudre ce problème, sur la base de la réponse de XXavier, tout le crédit vient à lui, merci beaucoup


0 commentaires