Python Forum
function returns dataframe as list - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: function returns dataframe as list (/thread-37952.html)



function returns dataframe as list - harum - Aug-13-2022

Hello, I have a function that takes a dataframe as an argument and returns a modified dataframe; and the modified dataframe is a dataframe object as checked with isinstance before return. However, in the calling function the variable assigned to the returned dataframe is no longer a dataframe but a list. Any ideas why would that be? Thanks!


RE: function returns dataframe as list - harum - Aug-13-2022

(Aug-13-2022, 08:04 PM)harum Wrote: Hello, I have a function that takes a dataframe as an argument and returns a modified dataframe; and the modified dataframe is a dataframe object as checked with isinstance before return. However, in the calling function the variable assigned to the returned dataframe is no longer a dataframe but a list. Any ideas why would that be? Thanks!


If anyone is interested, it was a newbie mistake, used "return [dataframe_name]" instead of "return dataframe_name".


RE: function returns dataframe as list - rob101 - Aug-13-2022

(Aug-13-2022, 08:19 PM)harum Wrote: used "return [dataframe_name]"

Yes, that would do it.

Good that you worked it out: that's learning, right there.