Pandas:在创建DataFrame时指定列标签返回NaN

时间:2014-11-20 16:46:32

标签: python pandas

以下代码返回具有NaN值的数据框。

my_columns = ['Current', 'In 6 Months', 'Under Stress']
my_index = ['Liquid Assets', 'Cash & Short Duration Bonds', 'Illiquid Assets']
combined_df = pd.DataFrame([curr_data, in6m_data, understress_data], index = my_index, columns = my_columns)

虽然这很有效。

my_columns = ['Current', 'In 6 Months', 'Under Stress']
my_index = ['Liquid Assets', 'Cash & Short Duration Bonds', 'Illiquid Assets']
combined_df = pd.DataFrame([curr_data, in6m_data, understress_data], index = my_index)
combined_df.columns = my_columns


curr_data
0    4.490472e+09
1    2.911620e+08
2    6.931839e+08
Name: Current, dtype: float64

in6m_data
0    4.031035e+09
1    2.910907e+08
2    5.764309e+08
Name: In 6 Months, dtype: float64

understress_data
0    8.127460e+08
1    3.324597e+08
2    2.656221e+09
Name: Under Stress, dtype: float64

任何人都知道原因/差异吗?

0 个答案:

没有答案