Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hi guys, since its so quiet here

Hi guys, since its so quiet here

Hi guys, since its so quiet here

Hi guys,

since its so quiet here ,let me throw in another easy one. The problem is, that I'm so used toSQL and using "Where"..So here goes..


gives me a select count...

now how I can add a condition to only list those above a certain number, say 3?

I tried this...


..which just gave me my list with true and false on each column.

Thanks in advance

RE: Hi guys, since its so quiet here

Is df a panda's dataframe?

RE: Hi guys, since its so quiet here

yes, df is the general short term for any panda dataframe

RE: Hi guys, since its so quiet here

it would be helpful if you could post how your data looks like.

RE: Hi guys, since its so quiet here

I tried this:
first I created this data frame from a list of items


>>> my_list = ['foo', 'bar', 'baz', 'foo', 'bar', 'foo', 'bar', 'foo']

>>> my_df=pd.DataFrame({"item" : my_list})

>>> my_df
0  foo
1  bar
2  baz
3  foo
4  bar
5  foo
6  bar
7  foo 

Now I can get a list of items which occurs more than once in these steps:


>>> my_df["item"].value_counts()>1
foo     True
bar     True
baz    False
Name: item, dtype: bool

>>> my_df.loc[(my_df["item"].value_counts()>1).values]
0  foo
1  bar

>>> list((my_df.loc[(my_df["item"].value_counts()>1).values])["item"])
['foo', 'bar'] 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close