gpt4 book ai didi

python - 从 MultiIndex 中选择特定级别

转载 作者:行者123 更新时间:2023-12-01 00:43:39 25 4
gpt4 key购买 nike

我有以下代码:

idx1 = sys_bal.index
idx2 = user_bal.index
idx3 = idx1.intersection(idx2)

生成以下输出:

MultiIndex(levels=[[3, 29193], ['1WO', 'ABX', 'ADH', 'ALX', 'AMLT', 'BCH', 'BRC', 'BSV', 'BTC', 'BTRN', 'CAN', 'CEL', 'CHI', 'CMCT', 'COT', 'CRPT', 'DACS', 'DAI', 'DASH', 'DENT', 'DREAM', 'DRG', 'EARTH', 'ECH', 'ENJ', 'ETC', 'ETH', 'ETN', 'EZT', 'FANZ', 'FCT', 'FDX', 'FFC', 'FLIXX', 'FLP', 'FSN', 'FTT', 'FTX', 'GAT', 'GEN', 'GET', 'GUSD', 'GXC', 'GZE', 'HART', 'HERO', 'HOT', 'ICASH', 'IDH', 'IGNX', 'IHF', 'IND', 'IPSX', 'IXT', 'KRL', 'LALA', 'LDC', 'LIKE', 'LND', 'LTC', 'MCO', 'MFUN', 'MGO', 'MITH', 'MITX', 'MRK', 'MT', 'MTN', 'NEO', 'NPLC', 'OAX', 'OMG', 'ONG', 'ONT', 'ORBS', 'PAL', 'PLG', 'PMA', 'PPL', 'PWV', 'QASH', 'QCTN', 'QTUM', 'RBLX', 'REP', 'RFOX', 'SAL', 'SER', 'SGN', 'SIX', 'SNIP', 'SNX', 'SPHTX', 'SPIKE', 'STAC', 'STACS', 'STORJ', 'STU', 'STX', 'THRT', 'THX', 'TPAY', 'TPT', 'TRX', 'TTU', 'UBT', 'UBTC', 'UKG', 'USDC', 'VANY', 'VET', 'VUU', 'VZT', 'WIN', 'WLO', 'XEM', 'XES', 'XLM', 'XMR', 'XNK', 'XRP', 'XTX', 'ZCO', 'ZEC', 'ZPR']],
labels=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 5, 8, 26, 80, 120]],
names=['app_vendor_id', 'currency'],
sortorder=0)

你能帮我只选择第二级列表吗?

['1WO', 'ABX', 'ADH', 'ALX', 'AMLT', 'BCH', 'BRC', 'BSV', 'BTC', 'BTRN', 'CAN', 'CEL', 'CHI', 'CMCT', 'COT', 'CRPT', 'DACS', 'DAI', 'DASH', 'DENT', 'DREAM', 'DRG', 'EARTH', 'ECH', 'ENJ', 'ETC', 'ETH', 'ETN', 'EZT', 'FANZ', 'FCT', 'FDX', 'FFC', 'FLIXX', 'FLP', 'FSN', 'FTT', 'FTX', 'GAT', 'GEN', 'GET', 'GUSD', 'GXC', 'GZE', 'HART', 'HERO', 'HOT', 'ICASH', 'IDH', 'IGNX', 'IHF', 'IND', 'IPSX', 'IXT', 'KRL', 'LALA', 'LDC', 'LIKE', 'LND', 'LTC', 'MCO', 'MFUN', 'MGO', 'MITH', 'MITX', 'MRK', 'MT', 'MTN', 'NEO', 'NPLC', 'OAX', 'OMG', 'ONG', 'ONT', 'ORBS', 'PAL', 'PLG', 'PMA', 'PPL', 'PWV', 'QASH', 'QCTN', 'QTUM', 'RBLX', 'REP', 'RFOX', 'SAL', 'SER', 'SGN', 'SIX', 'SNIP', 'SNX', 'SPHTX', 'SPIKE', 'STAC', 'STACS', 'STORJ', 'STU', 'STX', 'THRT', 'THX', 'TPAY', 'TPT', 'TRX', 'TTU', 'UBT', 'UBTC', 'UKG', 'USDC', 'VANY', 'VET', 'VUU', 'VZT', 'WIN', 'WLO', 'XEM', 'XES', 'XLM', 'XMR', 'XNK', 'XRP', 'XTX', 'ZCO', 'ZEC', 'ZPR']

最佳答案

选择第二级输出MultiIndex:

out = idx3.levels[1]

如果需要所有值(可能有重复):

out = idx3.get_level_values(1)

关于python - 从 MultiIndex 中选择特定级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57160759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com