Issue
I'm starting to use logging to an output file but can't see how to log the head of a data-frame. Is it possible?
I've tried debug (logger.debug("snaptable", snap_date.head()
), where snap_table is a data-frame, but I can't see any output when I interrogate the output file.
Is there a type of logging that can do this?
Solution
snap_date.head()
returns pandas.core.frame.DataFrame
object:
>>> type(snap_date.head())
pandas.core.frame.DataFrame
You should convert it to str, because logger.debug arguments (msg and *args) must be format string and string arguments. Try pandas.DataFrame.to_string:
logger.debug("Snap_date:\n %s", snap_date.head().to_string())
Answered By - Sanjar Adilov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.