Ask Your Question

How to drop rows according to a specific numerical column entry

asked 2020-06-24 07:35:01 +0200

Cyrille gravatar image

updated 2020-06-24 07:59:45 +0200

I ask the following question which is more pure Python than Sage, since I am mixing both.

I have a dataframe and one column looks like that

image description

I would like to keep only the non rows or to drop the numeric ones. I have not found a way to do that in Pandas. As you see the numerical values can change --- in the contrary it would be easy.

When I try something like

feuille_utilise[feuille_utilise['Entreprise liée'].str.contains("non")]

I obtain the following message

Cannot mask with non-boolean array containing NA / NaN values

edit retag flag offensive close merge delete


Please add a (small) self-contained example code, always.

rburing gravatar imagerburing ( 2020-06-24 11:22:20 +0200 )edit

Your data seem to come from R (Neither Python nor Sage have native "dataframe" structrure). Why not use R for handling this task ? This can be done from Sage : have a look at the R interface...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-06-24 12:11:02 +0200 )edit

no my data comes from excel

Cyrille gravatar imageCyrille ( 2020-06-24 12:56:46 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2020-06-24 18:58:39 +0200

Sébastien gravatar image

The syntax to filter rows of a dataframe in pandas is the following:

feuille_utilise[feuille_utilise['Entreprise liée'] == "non"]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-06-24 07:35:01 +0200

Seen: 109 times

Last updated: Jun 24 '20