多重索引2024年8月29日 | 1 分钟阅读 多重索引被定义为非常重要的索引,因为它处理数据分析和操作,特别是处理更高维度的数据。它还支持在较低维度的数据结构(如 Series 和 DataFrame)中存储和操作具有任意维度数量的数据。 它是标准索引对象的分层模拟,用于存储 pandas 对象中的轴标签。它也可以定义为元组数组,其中每个元组都是唯一的。它可以从数组列表、元组数组和交叉的可迭代对象集创建。 示例 输出 [('it', 'one'),
('it', 'two'),
('of', 'one'),
('of', 'two'),
('for', 'one'),
('for', 'two'),
('then', 'one'),
('then', 'two')]
示例 2 输出 MultiIndex([('bar', 'one'),
[('it', 'one'),
('it', 'two'),
('of', 'one'),
('of', 'two'),
('for', 'one'),
('for', 'two'),
('then', 'one'),
('then', 'two')]
names=['first', 'second'])
Example3 输出 MultiIndex(levels=[[nan, None, NaT, 128, 2]],
codes=[[0, -1, 1, 2, 3, 4]])
下一主题Pandas Reindex |
我们请求您订阅我们的新闻通讯以获取最新更新。