Most people read a CSV file with poorly named columns and then rename them afterward. If you’re one of those people, stop doing that. Below is a dataframe showing a CSV file read with original column names.
df1 = pl.read_csv('data.csv')df1
shape: (5, 2)
Col1
Col2
str
str
"Spencer"
"Bossy"
"Emily"
"Sporty"
"Hannah"
"Artistic"
"Aria"
"Word smith"
"Mona"
"Manipulative"
Assign column names on read
To assign column names as you read the CSV file, use the parameter new_columns and list the new columns names.