小编the*_*lin的帖子

python - 检查nan是否在字典中浮动

import numpy as np
import pandas as pd
import tia.bbg.datamgr as dm
mgr = dm.BbgDataManager()

bb_yearb4 = "2016-12-30"
bb_today = "2017-09-22"

indices = [list of indices]
sids_index = mgr[indices]
df_idx = sids_index.get_historical('PX_LAST', bb_yearb4, bb_today)

nan = np.nan

price_test = {}
for index in indices:
    price_test["{0}".format(index)] = df_idx.loc[bb_today][index]
Run Code Online (Sandbox Code Playgroud)

输出显示多个nan浮点值:

In [1]: price_test.values()
Out[1]: [nan, nan, nan, 47913.199999999997, nan, 1210.3299999999999, nan]
Run Code Online (Sandbox Code Playgroud)

然而,测试nan显示错误:

In [2]: nan in price_test.values()
Out[2]: False
Run Code Online (Sandbox Code Playgroud)

测试这个的正确方法是什么?

dictionary numpy nan python-2.7 pandas

5
推荐指数
1
解决办法
3911
查看次数

标签 统计

dictionary ×1

nan ×1

numpy ×1

pandas ×1

python-2.7 ×1