Issue
When trying to write a dataframe to csv I get the following error:
In [197]: schdfarrdf.to_csv(ss, sep=',')
[SpyderKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\ipykernel\kernelbase.py", line 409, in dispatch_shell
await result
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\ipykernel\kernelbase.py", line 798, in inspect_request
reply_content = self.do_inspect(
^^^^^^^^^^^^^^^^
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\ipykernel\ipkernel.py", line 555, in do_inspect
bundle = self.shell.object_inspect_mime(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\interactiveshell.py", line 1838, in object_inspect_mime
return self.inspector._get_info(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\oinspect.py", line 738, in _get_info
info_dict = self.info(obj, oname=oname, info=info, detail_level=detail_level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\oinspect.py", line 838, in info
if info and info.parent and hasattr(info.parent, HOOK_NAME):
File "C:\Users\mtc20tfq\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\generic.py", line 1466, in __nonzero__
raise ValueError(
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
the .csv file seems to write correctly, but I dont understand why the error occurs, or what it is!
Solution
That looks like a Spyder/ipython bug. You might be able to work around it by adding a second statement such as 0
here
schdfarrdf.to_csv(ss, sep=','); 0
so the REPL doesn't try (and fail) to interpret the result of the to_csv
call.
Answered By - AKX
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.