Generate Column Name Lookup in Python

Asker: ignoring_gravity

Kyle Pastor
RE:Stacked
Published in
2 min readJul 14, 2023

--

Photo by Alex Chumak on Unsplash

Disclaimer: Solution by ChatGPT and validated by human.

Question

Say I have

df = pl.DataFrame({
'a': [1, 2, 1],
'b': [2, 1, 2],
'c': [3, 3, 2],
'column': ['a', 'c', 'b'],
})
shape: (3, 4)
┌─────┬─────┬─────┬────────┐
│ a ┆ b ┆ c ┆…

--

--

Kyle Pastor
RE:Stacked

Analytics | Full Stack | Data Science | MS Physics + MS Quant Finance → http://kapastor.github.io/