One way to convert to string is to use astype:
total_rows[‘ColumnID’] = total_rows[‘ColumnID’].astype(str)
However, perhaps you are looking for the to_json function, which will convert keys to valid json (and therefore your keys to strings):
In [11]: df = pd.DataFrame([[‘A’, 2], [‘A’, 4], [‘B’, 6]])
In [12]: df.to_json()
Out[12]: ‘{“0”:{“0″:”A”,”1″:”A”,”2″:”B”},”1″:{“0″:2,”1″:4,”2”:6}}’
In [13]: df[0].to_json()
Out[13]: ‘{“0″:”A”,”1″:”A”,”2″:”B”}’
Note: you can pass in a buffer/file to save this to, along with some other options…
If you need to convert ALL columns to strings, you can simply use:
df = df.astype(str)
This is useful if you need everything except a few columns to be strings/objects, then go back and convert the other ones to whatever you need (integer in this case):
df[[“D”, “E”]] = df[[“D”, “E”]].astype(int)