×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

(OP)
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..

df['artist'].value_counts().reset_index()

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...

df.groupby('artist').count()>3

..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

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

RE: Hi guys, since its so quiet here

kingz2000,
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

CODE

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

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

>>> my_df
  item
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:

CODE

>>> 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]
  item
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