Dynamically adding columns to a table

I’ve looked around but haven’t been able to find anything on this - is it possible to add/remove columns from an existing plotly table? I want to create a legend click event that either adds/removes or displays/hides a column from a table if the corresponding trend line is selected.

Here’s one way https://codepen.io/etpinard/pen/YJdYQW?editors=1010

Perfect. Simple and clean, I was making it way too hard for myself. I appreciate it!