我希望能够存储'单位' DataFrame的每一列的信息,并具有以下代码(uisng pandas v 0.14.1):
import pandas as pd
import numpy as np
import copy
# Monkey path Series:
pd.Series._metadata.append('units')
# Test it
df = pd.DataFrame(data=np.random.randn(5,2), columns=['A', 'B'])
df['A'].units = 's'
df['B'].units = 'm'
s = df['A']
print s.units # produces 's' as expected / desired
s = copy.copy(df['A'])
print s.units # crash, attribute does not exists
print s._metadata # produces ['name', 'units'] as expected
显然,元数据未正确传播。 这是故意还是这个错误? 如果有意做什么可以使这项工作?