Here you go with filter
df.groupby('city').filter(lambda x : len(x)>3)
Out[1743]:
city
0 NYC
1 NYC
2 NYC
3 NYC
Solution two transform
sub_df = df[df.groupby('city').city.transform('count')>3].copy()
# add copy for future warning when you need to modify the sub df
More Related Contents:
- How are iloc and loc different?
- How to convert index of a pandas dataframe into a column
- How to reset index in a pandas dataframe? [duplicate]
- What rules does Pandas use to generate a view vs a copy?
- Pandas split DataFrame by column value
- Selecting a row of pandas series/dataframe by integer index
- What is the difference between using squared brackets or dot to access a column?
- Accessing Pandas column using squared brackets vs using a dot (like an attribute)
- Get column index from column name in python pandas
- Pandas groupby.size vs series.value_counts vs collections.Counter with multiple series
- Python Pandas: Get index of rows where column matches certain value
- Using replace efficiently in pandas
- In Python pandas, start row index from 1 instead of zero without creating additional column
- Selecting a range of columns in a dataframe
- How to efficiently assign unique ID to individuals with multiple entries based on name in very large df
- start index at 1 for Pandas DataFrame
- How to split a dataframe string column into two columns?
- Annotate bars with values on Pandas bar plots
- Comparing two dataframes and getting the differences [duplicate]
- Pandas Groupby and Sum Only One Column
- Pandas Dataframe: Replacing NaN with row average
- How to read a .xlsx file using the pandas Library in iPython?
- Pandas Replace NaN with blank/empty string
- How to append rows in a pandas dataframe in a for loop?
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- How to reorder indexed rows based on a list in Pandas data frame
- Trying to merge 2 dataframes but get ValueError
- Python pandas integer YYYYMMDD to datetime
- Replace NaN with empty list in a pandas dataframe
- When is it appropriate to use df.value_counts() vs df.groupby(‘…’).count()?