Code Sample, a copy-pastable example if possible
import pandas as pd
df = pd.DataFrame({'a': [1, '2']})
df.to_hdf('tmp.h5', 'key', format='table')
Problem description
I wonder if there is a reason why the exception message contains a line break:
TypeError: Cannot serialize the column [a] because
its data contents are [mixed-integer] object dtype
The line breaks are explicitly introduced in module pandas/io/pytables.py:
raise TypeError(
"Cannot serialize the column [%s] because\n"
"its data contents are [%s] object dtype"
% (item, inferred_type)
)
It should be noted that besides this message, there are many others exception massages with line breaks in this module.
I make this question because I am logging the output and I think it would be better to have an event log per line.
Expected Output
TypeError: Cannot serialize the column [a] because its data contents are [mixed-integer] object dtype
Output of pd.show_versions()
Comment From: jreback
well line breaks make things easier to read
Comment From: jreback
certainly willing to take a patch to make this particular one a 1-liner if that is more readable. Though in general multi-lines is fine.
Comment From: albertvillanova
In a logfile, normally every line corresponds to one event message. Multi-line log messages create great difficulty in the usage of logfiles for monitoring purposes. Nevertheless, if the priority for Pandas is human readability then no fix is nedeed.