I have a dictionary like this:
{
"BTCUSDT":{
"bids":[["49030","0.006386"],["49035","0.007403"],["49050","0.006723"], ...],
"asks":[["49000","0.000306"],["48990","0.001"],["48940","0.019"], ...]
},
"ETHUSDT":{
"bids":[["4025.8","3.17806"],["4026","0.00999"],["4034","0.45"], ...],
"asks":[["4011.2","2.5622"],["4009","0.337"],["4003","0.81684"], ...]
},
"XRPUSDT":{
"bids":[["0.8259","2250"],["0.82669","193.5"],["0.827","31.7"], ...],
"asks":[["0.8222","59.2"],["0.82005","1217.6"],["0.82002","28.3"], ...]
},
...
...
...
}
Which is showing market orders of some cryptocurrency pairs and each list of bids and asks has a fixed number (24) of elements and each element has two values which respectively are showing order price and order amount.
I'm really an amateur in pandas and NumPy! So what I want to do is to create a DataFrame of this dictionary (let's name it df) and get the first bid or ask of all of the pairs in a single line like this:
[In]: df.loc[:,'bids',0]
[Out]: BTCUSDT [49030, 0.00638]
ETHUSDT [4025.8, 3.17806]
XRPUSDT [0.8259, 2250]
...
...
I've tried a lot of ways but none of them worked as I wanted them to!
Addition: As far as possible, I want to avoid using loops :)