Python Forum
function returns dataframe as list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function returns dataframe as list
#1
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!
Reply
#2
(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".
Gribouillis likes this post
Reply
#3
(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.
harum likes this post
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using .append() with list vs dataframe Mark17 7 10,525 Jun-12-2022, 06:54 PM
Last Post: Mark17
  function accepts infinite parameters and returns a graph with those values edencthompson 0 867 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  List of dataframe values beginning with x,y or z glidecode 3 1,946 Nov-08-2021, 10:16 PM
Last Post: glidecode
  Reading data to python: turn into list or dataframe hhchenfx 2 5,397 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  function that returns a list of dictionaries nostradamus64 2 1,765 May-06-2021, 09:58 PM
Last Post: nostradamus64
  convert list to five columns dataframe in sequence tonycat 2 2,489 Sep-29-2020, 06:47 AM
Last Post: tonycat
  Recursive function returns None, when True is expected akar 0 3,398 Sep-07-2020, 07:58 PM
Last Post: akar
  How to map dataframe to list Mekala 1 1,639 Aug-09-2020, 12:07 AM
Last Post: scidam
  Get Value from List to Show in DataFrame Column ahmedwaqas92 1 1,909 Jun-22-2020, 08:24 AM
Last Post: ahmedwaqas92
  Python function returns inconsistent results bluethundr 4 3,201 Dec-21-2019, 02:11 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020