pandas中是否有一种方法可以为pandas数据框的同一列提供两个名称,这样我就可以只用两个名称中的一个来索引列?这是一个说明我问题的快速示例:
import pandas as pd
index=['a','b','c','d']
# The list of tuples here is really just to
# somehow visualize my problem below:
columns = [('A','B'), ('C','D'),('E','F')]
df = pd.DataFrame(index=index, columns=columns)
# I can index like that:
df[('A','B')]
# But I would like to be able to index like this:
df[('A',*)] #error
df[(*,'B')] #error