Note that there are some explanatory texts on larger screens.

plurals
  1. POfilter rows based on a True value in a column - python pandas data frame
    text
    copied!<p>I am working with pandas dataframe. I am interested in obtaining a new data frame based on a condition applied to a column of a already existing datafame. Here is the dataframe:</p> <pre><code>users_df Out[30]: &lt;class 'pandas.core.frame.DataFrame'&gt; Index: 3595 entries, Data columns (total 9 columns): screen_name 3595 non-null values User_Desc 3595 non-null values lang 3595 non-null values followers_count 3579 non-null values friends_count 3580 non-null values listed_count 2665 non-null values statuses_count 3595 non-null values stem_key_flag 3595 non-null values stem_keys 3595 non-null values dtypes: bool(1), float64(3), int64(1), object(4) </code></pre> <p>What I am doing is </p> <pre><code>en_users_df = users_df[users_df['stem_key_flag']==True] </code></pre> <p>but I get exacly the same answer as top code block. Which means it not filtering anything. Am I doing something which was compatible in earlier version but not now ? If not, what is the mistake I am making ?</p> <p>I also tried similar approach with the another column which is an int data type and it works fine.</p> <pre><code>fol_cnt_users_df = users_df[users_df['followers_count'] &gt;1000] In [35]: fol_cnt_users_df Out[35]: &lt;class 'pandas.core.frame.DataFrame'&gt; Index: 724 entries, 2013-06-20, 12:13:46 to 2013-06-19, 18:26:48 Data columns (total 9 columns): screen_name 724 non-null values User_Desc 724 non-null values lang 724 non-null values followers_count 724 non-null values friends_count 722 non-null values listed_count 714 non-null values statuses_count 724 non-null values stem_key_flag 724 non-null values stem_keys 724 non-null values dtypes: bool(1), float64(3), int64(1), object(4) </code></pre> <p>Thanks for the help in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload