Dict cannot be saved as json no matter what


I am trying to save a dict to json but no matter what I try I get either errors that

Object of type DataFrame is not JSON serializable OR
Dict object has no attribute to json

I follow many tutorials on how to do that eg

json = json.dumps(pdData)

f = open("dict.json","w")

# write json object to file


# close file


But still I get errors like the aboves.

Any advice? Thanks

You need to show us the actual code you are running, and the full
traceback, not just a summary or approximate version.

Please look at these first:


Try to cut your example down to the smallest self-contained example that
we can run, without needing access to your data files. Normally I would
expect an example to need no more than half a dozen lines of code,
although of course that can vary.

Don’t forget to copy and paste the full traceback of the exceptions that
you get, not just the final error message.