Issue
My sample function that returns a pandas data frame.
def myFunction(data, row, col):
return pd.DataFrame(
{
"helloWorld": [data["helloWorld"][row][col]],
}
)
How can I convert this pandas dataframe to a list?
Docs & References:
https://datatofish.com/convert-pandas-dataframe-to-list/
https://www.geeksforgeeks.org/how-to-convert-pandas-dataframe-into-a-list/
Solution
Use .values.tolist()
def myFunction(data, row, col):
return pd.DataFrame(
{
"helloWorld": [data["helloWorld"][row][col]],
}
).values.tolist()
Answered By - Stephen Stilwell
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.