Hi :slightly_smiling_face: I want to pass a `pd.Da...
# ask-community
e
Hi 🙂 I want to pass a
pd.DataFrame
to a task, but it failed when querying GraphQL since
pd.DataFrame
isn’t json serializable
Copy code
~/Library/Caches/pypoetry/virtualenvs/recipe-t7nMXg6Y-py3.8/lib/python3.8/site-packages/prefect/client/client.py in graphql(self, query, raise_on_error, headers, variables, token, retry_on_api_error)
    550             server=self.api_server,
    551             headers=headers,
--> 552             params=dict(query=parse_graphql(query), variables=json.dumps(variables)),
    553             token=token,
    554             retry_on_api_error=retry_on_api_error,
I can pass
df.dict()
and deserialize it, but I rather not
a
@Eric Feldman you can pass dataframe to a task, if one task returns a dataframe, and another one receives it as data dependency. But you can’t pass a dataframe to a GraphQL query, because Pandas dataframe, as you correctly noticed, is a Python object which is not JSON serializable in a way that you could pass it to a GraphQL query in a raw format.
e
its not me calling the graphql, thats part of the flow I ran
Copy code
flow_run_id = client.create_flow_run(flow_id, parameters={'data': pd.DataFrame({'n': [1,2,3]})})
k
This
create_flow_run
is an API call under the hood and you can’t pass pd.DataFrames through API calls in general as they rely on JSON for the payload.