'changing dtype in polars

i created a data frame using polars. when datas are inserted, dtype of the coulmn automatically changes to what inserted. (i think its a feature of polars?) but how do you change the dtype of speicfic table? for example "name" has f32 by default when theres no data but i want "name" to have utf8 or string even when theres no data. so i can make IF condition to find datas by name or w/e.

┌──────┬──────┬──────┬──────┬────────────┬───────┬──────┐
│ xmin ┆ ymin ┆ xmax ┆ ymax ┆ confidence ┆ class ┆ name │
│ ---  ┆ ---  ┆ ---  ┆ ---  ┆ ---        ┆ ---   ┆ ---  │
│ f32  ┆ f32  ┆ f32  ┆ f32  ┆ f32        ┆ f32   ┆ f32  │
╞══════╪══════╪══════╪══════╪════════════╪═══════╪══════╡
└──────┴──────┴──────┴──────┴────────────┴───────┴──────┘
# what i wanna do 
if boxes[(boxes['name']=='star')]: 
    blah blah blah

# above code gives me an error 
ValueError: could not convert string to float: 'star'




 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source