Pandas rolling appears only to return the real part of complex values...
Am I missing something?
a=np.array([[1+0j,2+0j,3+0j],[4j,5j,10+6j]])
pd.DataFrame(a.T).rolling(3).apply(lambda x: print(x) is None)
Output:
0 1
1 2
2 3
dtype: float64
0 0
1 0
2 10
dtype: float64
0 1
0 NaN NaN
1 NaN NaN
2 1 1
Note that the problem is not with apply. When apply is used without rolling, the entire complex value is passed to the lambda function:
a=np.array([[1+0j,2+0j,3+0j],[4j,5j,10+6j]])
pd.DataFrame(a.T).apply(lambda x: print(x) is None)
Output:
0 1+0j
1 2+0j
2 3+0j
Name: 0, dtype: complex128
0 0+4j
1 0+5j
2 10+6j
Name: 1, dtype: complex128
0 True
1 True
dtype: bool
** Note: this is not a question of whether or not to use rolling - but rather about the behavior of rolling with complex values.