Hi @regulus! Welcome!
Can you please try turning your question into a reproducible example (follow the link for instructions and explanations). You should include any code you’ve already tried, even if it doesn’t work.
Without a reproducible example, I’m afraid a question like this sometimes comes across as impolite: as though the asker is expecting other people to write their code for free. Certainly you are asking a helper to at least write some code to construct a sample data frame before they can get started on your puzzle. Instead, I think that if you set it all up nicely for your helpers and show the dead ends you’ve already found, you’ll be much more likely to attract interested people to your problem.