Ask Your Question
0

How to drop rows according to a specific numerical column entry

asked 2020-06-24 00:35:01 -0500

Cyrille gravatar image

updated 2020-06-24 00:59:45 -0500

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

Comments

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

rburing gravatar imagerburing ( 2020-06-24 04:22:20 -0500 )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 05:11:02 -0500 )edit

no my data comes from excel

Cyrille gravatar imageCyrille ( 2020-06-24 05:56:46 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2020-06-24 11:58:39 -0500

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

Stats

Asked: 2020-06-24 00:35:01 -0500

Seen: 40 times

Last updated: Jun 24