How can I parse strings using the same logic Pandas would use when reading a CSV, where casting "False" to bool would give me False. I have text values entered by users that I need to insert into a DataFrame, they should automatically be cast to the dtype of the column being inserted to using this logic. The example below shows an attempt to insert a value into a boolean column but the result is wrong.
import pandas as pd
x = pd.DataFrame([{'id': 0, 'flag': True},
{'id': 1, 'flag': False},
{'id': 2, 'flag': True}])
text = "False"
value = x['flag'].dtype.type(text) # Want this to be False not True
x.loc[0, 'flag'] = value