Dataframe Pandas - Apply the groupby of a column to other rows

Asked

Viewed 227 times

0

Hello, I have a dataframe with a 'Time' column and 6 other columns. I only need data based on duplicate values of 'Time'. So, I already used groupby and created the "Pico" column which is where the values repeat. However, I wanted to separate now the other 6 columns based on it. Example, stay with the line 1421 and 1422 all. Someone? inserir a descrição da imagem aqui

*EDIT I got what I wanted using: df[(df['Repeated']=2)] inserir a descrição da imagem aqui In this case, I can see the whole horizon of repeated values based on 'Time'

1 answer

0


Just filter the non-null elements from the 'Pico' column, like this:

df = df[df['Pico'].notnull()]

EDIT: If you only need to filter the repeated values, without any other type of operation involved, you can also use the function duplicated of dataframe with keep=False keeping all repetitions, thus:

df = df[df.duplicated(keep=False)]
  • Hi, I was able to do what I wanted but using: clean = df[(df['Repeaters']=2)] and then I was able to visualize the entire horizon only of those that were equal to 2, including all other columns. The problem of filtering the repeated values only of the other columns is that there are "repeated values" that were not meant to be repeated, and I ended up having problems, let’s say my repeated data selection thermometer was that of 'Time' only. Anyway, thank you so much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.