I have the following dataframe
time X Y X_t0 X_tp0 X_t1 X_tp1 X_t2 X_tp2 0 0.002876 0 10 0 NaN Na
df.replace only replaces the first occurrence on the value and thus the error
df.replace
df = list(filter(lambda x: x!= inf, df)) would remove all occurrences of inf and then the drop function can be used
df = list(filter(lambda x: x!= inf, df))
inf
drop