-1

I have a DataFrame of 2 columns,

Index - which are grouped code numbers

frequency - which is the no of elements in that group.

I want to find the elements in that group. How do I do it?

I tried using MY_DF = DF_1.get_group('12345678') . It gives me

AttributeError: 'DataFrame' object has no attribute 'get_group'

Expected output is rows and columns of elements having code no 12345678

Chris
  • 29,127
  • 3
  • 28
  • 51

2 Answers2

0

Filtering on columns can be done with:

my_df = df[column_name=='12345678']

Consider to read and learn pandas basics: https://pandas.pydata.org/pandas-docs/stable/getting_started/10min.html

Joost Döbken
  • 3,450
  • 2
  • 35
  • 79
0

Your questions a bit vague, it would be nice if you can provide a sample df / some code you tried.

From your question is looks like you are looking for something like:

MY_DF.groupby(['Index', 'frequency']).size()

You could also create a dataframe from it using:

MY_DF.groupby(['Index', 'frequency]).size().reset_index(name='counts')

See this link for more information.

McBait
  • 57
  • 5