If I understand csv.QUOTE_MINIMAL correctly, pandas DataFrame.to_csv quotes only the fields which contains any of the delimiter, quotechar or lineterminator.
However my CSV is then processed by a program that requires other characters to be in quotes, how can I do that without quoting everything with QUOTE_NONNUMERIC or QUOTE_ALL ?
For instance how can I escape if there is a \t or \r ?
> df = pd.DataFrame({"a": [1,2,3,4], "b": ["b1", "b\r2", "b\t3", "b4"]})
> df.to_csv(index=False)
This returns 'a,b\n1,b1\n2,b\r2\n3,b\t3\n4,b4\n'
But I want field b of row 2 and 3 to be escaped: 'a,b\n1,b1\n2,"b\r2"\n3,"b\t3"\n4,b4\n'