I have the following strings :
d1 = "[{'col 1':'a','col 2':'b'}]"
d2 = '[{"col 1":"a","col 2":"b"}]'
These strings contains the same data.
I only inverted the use of single and double quotes.
But for read_json
they are not the same :
>>> pd.read_json(d1, orient='records')
# builtins.ValueError: Expected object or value
>>> pd.read_json(d2, orient='records')
# col 1 col 2
# 0 a b
I have done some unsuccessful research and I don't understand what's going on.
So I have done some tests :
>>> type(d1)
# <class 'str'>
>>> type(d2)
# <class 'str'>
>>> d1==d1
# True
>>> d2==d2
# True
>>> d1==d2
# False
So same type (str), same content but they are not equal. Why ?