我有一个包含以下列的数据帧:
amount1 - a numeric value
amount2 - a different numeric value
ccy1 - a 3-char currency code
ccy2 - a different 3-char currency code
数据被组织成这样的行,其中元组(amount1,ccy1,amount2,ccy2)将与由元组(amount2,ccy2,amount1,ccy1)组成的另一行完全对应
我要做的是把我的数据帧分成两部分。在df1中,我希望包括ccy1>;=ccy2(按字母顺序排序)的行;在df2中,我希望包括cc1<;ccy2的行。在
我编写了一个简单的函数来进行拆分:
^{pr2}$但在我的新专栏中却遇到了困难,我正在尝试:
df['splitter'] = splitfunctest(df['ccy1'], df['ccy2'])
但是得到:
Traceback (most recent call last): File "", line 1, in File "", line 2, in splitfunctest ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
所以我可以看到这个函数正在尝试(但失败了)计算传递给它的每个字段的全部内容-那么我如何让它以原子方式运行呢?-任何帮助都将不胜感激。在
试试这个:
相关问题 更多 >
编程相关推荐