I try to filter a dataframe using the following expression: I am seeking the times “col” changes to “val”:
filtered_df = df[(df[col]== val) & (df.shift(1)[col] != df[col])]
df is a dataframe that is generated by a function: df= create_df(data)
The filtered_df is empty even though there condition is verified at least one time in my data.
When I try to export my df to a csv file:
data = pd.to_csv("out")
then
Apply the above filter to data, it works, I get a non empty dataframe.
I don’t know how to explain this , “df” and “data” are meant to be the same.
Any help please? Thanks9