11月18日总结

用标签切片,包含行与列结束点:

In [28]: df.loc['20130102':'20130104', ['A', 'B']]
Out[28]: 
                   A         B
2013-01-02  1.212112 -0.173215
2013-01-03 -0.861849 -2.104569
2013-01-04  0.721555 -0.706771

返回对象降维:

In [29]: df.loc['20130102', ['A', 'B']]
Out[29]: 
A    1.212112
B   -0.173215
Name: 2013-01-02 00:00:00, dtype: float64

提取标量值:

In [30]: df.loc[dates[0], 'A']
Out[30]: 0.46911229990718628

快速访问标量,与上述方法等效:

In [31]: df.at[dates[0], 'A']
Out[31]: 0.46911229990718628
posted @ 2021-11-18 20:31  不详·Christina  阅读(24)  评论(0)    收藏  举报