TypeError: Object of type 'DataFrame' is not JSON serializable
Your df
is still a data frame because you haven't assigned it as json.
df = df.to_json()
This should work. Let me know if not.
df = pd.read_csv(data)
return_data = {
"status": 1,
"message": "Raw Data List with pagination",
"data": {
"is_header": is_header,
"head": **json.loads(df.head().to_json())**
}
}