I am trying to mock a dataframe for unit testing in python. here is the form of the table:
However, I am having trouble hard coding a dataframe to have a json within it. This is my attempt at mocking a record:
test_strip = pd.DataFrame(
[[1],
"2020-09-21",
[{'WTI': {'1604188800000': '40.25',
'1606780800000': '40.51',
'1609459200000': '40.81',
'1612137600000': '41.13',
'1614556800000': '41.45',
'1617235200000': '41.74',
'1619827200000': '42.00',
'1622505600000': '42.22'}
}],
[1]],
columns=['id','trade_date','prices','contract']
)
This yields the following error:
ValueError: 4 columns passed, passed data had 10 columns
So it appears it is interpreting my json as separate records. Appreciate any help anyone might have.
Aucun commentaire:
Enregistrer un commentaire