【发布时间】:2018-02-22 04:28:30
【问题描述】:
我正在使用 Python 的 Pandas 库进行一些加密货币分析。我制作了以下数据框:
coin old_price current_price
0 BNBBTC 0.000949 0.000994
1 BNBETH 0.011472 0.012129
2 BNBUSDT 10.938950 9.358000
3 VENBNB 0.619480 0.635200
然后,我尝试比较 old_price 和 current_price 两列。
使用下面这行代码时:
comparison['sell'] = np.where((comparison['current_price'] >= comparison['old_price']))
我收到一条错误消息:
"ValueError: Length of values does not match length of index"
据我所知,数据框每列的数据数量相同。请指教,将不胜感激。
【问题讨论】:
-
@DyZ - 将 df 更正为比较 - 它与比较数据框中的其他列具有相同的形状
标签: python pandas dataframe comparison cryptocurrency