2017-02-09から1日間の記事一覧

<Python, pandas> 縦にずらす。

縦にずらす。 In [22]: df = pd.DataFrame({'a':[1,2,3,4,5,6]}) In [23]: df Out[23]: a 0 1 1 2 2 3 3 4 4 5 5 6 In [24]: df.shift(-1) Out[24]: a 0 2.0 1 3.0 2 4.0 3 5.0 4 6.0 5 NaN In [25]: df.shift(1) Out[25]: a 0 NaN 1 1.0 2 2.0 3 3.0 4 4.0 …

<Python, numpy> 無限大

知ってましたか? pythonで無限大は、np.infか、float('inf')で表現するらしいっす。 In [1]: float('inf') Out[1]: inf In [2]: float('inf') == 0 Out[2]: False In [3]: float('inf') < 1 Out[3]: False In [4]: float('inf') > 1 Out[4]: True In [5]: i…