I am new using pandas and I would really appreciate if someone can help me to solve this question.
I have the following dataframe:
import pandas as pd
# sample dataframe
df = pd.DataFrame({
'Price': [-3000, -262, 150, -3000, -262, 150, -3000, -262, 150, -3000, -262, 0],
'Volume': [8133, 28287, 19289, 20242, 19428, 28322, 18147, 17234, 12133,18147, 17234, 12133],})
print('Raw dataframe:')
print(df, '\n')
I want to get rid of those observations were the number of times that ¨price¨ appears is not equal to 4. In this example: -3000 and -262 are the only price observations that appear 4 times, therefore I would like just to keep those.
I would be really thankful if someone can help me.