将索引名称添加到pandas数据框

时间:2020-10-27 07:55:02

标签: python pandas dataframe dictionary

在我的代码中,我会逐渐填充一个熊猫数据框。 一开始它是空的。但是我已经知道应该使用哪个索引名称。

nodes_df = pd.DataFrame()
...
nodes_df = nodes_df.append([n_clength], ignore_index=True)
...
nodes_df.append([n_min_dist, n_closest_node_coord], ignore_index=True)

索引名称应为["clength", "dist", "cst_coord"]n_clength, n_min_dist and n_closest_node_coord是我要附加的字典。 我该如何预先或在添加字典时添加这些索引名称?

0 个答案:

没有答案