1from ast import literal_eval
2from io import StringIO
3
4# replicate csv file
5x = StringIO("""A,B
6,"('t1', 't2')"
7"('t3', 't4')",""")
8
9def literal_converter(val):
10 # replace first val with '' or some other null identifier if required
11 return val if val == '' else literal_eval(val)
12
13df = pd.read_csv(x, delimiter=',', converters=dict.fromkeys('AB', literal_converter))
14
15print(df)
16
17 A B
180 (t1, t2)
191 (t3, t4)
20