1

大批 :

    [{'base': 'BTC', 'target': 'USDT', 'market': {'name': 'Binance', 'identifier': 'binance', 'has_trading_incentive': False}, 'last': 40557.66, 'volume': 56710.07310532919, 'converted_last': {'btc': 0.99765331, 'eth': 14.387789, 'usd': 40502}, 'converted_volume': {'btc': 56577, 'eth': 815933, 'usd': 2296854073}, 'trust_score': 'green', 'bid_ask_spread_percentage': 0.010025, 'timestamp': '2022-02-28T15:25:20+00:00', 'last_traded_at': '2022-02-28T15:25:20+00:00', 'last_fetch_at': '2022-02-28T15:25:20+00:00', 'is_anomaly': False, 'is_stale': False, 'trade_url': 'https://www.binance.com/en/trade/BTC_USDT?ref=37754157', 'token_info_url': None, 'coin_id': 'bitcoin', 'target_coin_id': 'tether'}, {'base': 'BTC', 'target': 'USDT', 'market': {'name': 'Digifinex', 'identifier': 'digifinex', 'has_trading_incentive': False}, 'last': 40389.76, 'volume': 12057.3317597, 'converted_last': {'btc': 0.99851248, 'eth': 14.403808, 'usd': 40471}, 'converted_volume': {'btc': 12039, 'eth': 173671, 'usd': 487971237}, 'trust_score': 'green', 'bid_ask_spread_percentage': 0.077989, 'timestamp': '2022-02-28T15:27:05+00:00', 'last_traded_at': '2022-02-28T15:27:05+00:00', 'last_fetch_at': '2022-02-28T15:27:05+00:00', 'is_anomaly': False, 'is_stale': False, 'trade_url': 'https://www.digifinex.com/en-ww/trade/USDT/BTC', 'token_info_url': None, 'coin_id': 'bitcoin', 'target_coin_id': 'tether'}}]

结果 :

    base  target  market                                             last
0   BTC   USDT    {'name': 'Binance', 'identifier': 'binance', '...  40557.660000
1   BTC   USDT    {'name': 'Digifinex', 'identifier': 'digifinex...  40389.760000
....

I want results like this :
    base   target     market          last
0   BTC    USDT       Binance     40557.660000
1   BTC    USDT       Digifinex   40389.760000
....

df_tickers = pd.DataFrame(results, columns=['base', 'target', 'market', 'last']) df_tickers.set_index('base', inplace=True)

打印(df_tickers)

列表市场如何仅按名称显示?

4

1 回答 1

0

国际大学联合会,Series.str.get

df['market'] = df['market'].str.get('name')
于 2022-02-28T16:12:38.080 回答