'Why does this function return a tuple? [closed]

I have defined a fairly simple function that is having an unexpected output. I'm using Steam game reviews and want to use a function to narrow the scope based on game title. This works fine:

one_game = games[games['title'] == "Robocraft"]

The output is a dataframe just like the original. However, when I try to make a function (by passing the same game name as an argument) to slice the dataframe as follows:

def slice(game):
    out = games[games['title'] == game],
    return(out)

I get a tuple that is "[362 rows x 5 columns],)" instead of a dataframe. Is that because of the return command or is that just something that happens when you use a user defined function?

This seems like all I would need to do is convert the tuple back to a dataframe. However, I can't even do that! When I do, I get this error:

"ValueError: Must pass 2-d input. shape=(1, 362, 5)"

How can I get a dataframe as my output?

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source