✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Making traces persist without iterating through an entire dataframe

I have an animation with multiple traces on it.

It’s similar to this example.

However, I want one of the traces to have one row of the dataframe per frame (moving markers, with ~30 data points at every time step) and the other trace (sparse data, with one or two points every couple time steps) to have markers that persist – i.e., if a value appears in row 80, I want it to appear in every frame afterwards. My dataframe is pretty big – around 30k rows – so using the same approach as in that example (just iterating through every previous row, and then the current row, for each frame) leads to a lot of lag once the animation gets further along.

Is there any way to create persistent markers, or have the frame data for the second trace persist in some similar way?