小编ga9*_*asl的帖子

python数据帧中所有行的零索引

我在索引 python 时遇到问题dataframe。我有数据框,我用循环填充它。我把它简化成这样:

d = pd.DataFrame(columns=['img', 'time', 'key'])
for i in range(5):
    image = i
    timepoint = i+1
    key = i+2
    temp = pd.DataFrame({'img':[image], 'timepoint':[timepoint], 'key': [key]})
    d = pd.concat([d, temp])
Run Code Online (Sandbox Code Playgroud)

问题是因为它显示0为所有行的索引,我无法访问基于.loc[]. 有人知道如何解决问题并获得正常的索引列吗?

python indexing dataframe python-3.x pandas

3
推荐指数
2
解决办法
7052
查看次数

创建基于熊猫数据框的嵌套字典

我有一个这样的数据框

data = np.zeros((3,), dtype=[('A', 'a10'), ('B', 'f4'), ('C', 'f4')])
data[:] = [('key1', 1, 2), ('key2', 3, 4), ('key3', 5, 6)]
df = pd.DataFrame(data)
Run Code Online (Sandbox Code Playgroud)

我想将其转换为数据框字典,其中第一列将是字典的键。我怎样才能创建这样的字典?

dictionary python-3.x pandas

2
推荐指数
1
解决办法
321
查看次数

无法解析函数“deg2rad”

由于以下代码,我收到错误消息:

const double    angle = deg2rad(180);
Run Code Online (Sandbox Code Playgroud)

错误说:

Function 'deg2rad' could not be resolved
Run Code Online (Sandbox Code Playgroud)

我最近安装了“Eclipse IDE for C/C++ Developers”,并且在 C/C++ Build/Settings/Tool Settings/GCC C++ Compiler/Miscellaneous 的其他标志中添加了 -std=c++11

任何想法可能有什么问题?

c++

-4
推荐指数
1
解决办法
7030
查看次数

标签 统计

pandas ×2

python-3.x ×2

c++ ×1

dataframe ×1

dictionary ×1

indexing ×1

python ×1