Skip to content

Commit 7448a19

Browse files
code sample for pandas-dev#40662
1 parent e49d515 commit 7448a19

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bisect/40662.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# BUG: numpy functions (eg, np.add) on DataFrames with 'out' parameter no longer work properly #40662
2+
3+
import numpy as np
4+
import pandas as pd
5+
6+
print(pd.__version__)
7+
8+
# doesn't work. bar remains an array of zeros
9+
foo = np.array([1, 2, 3, 4]).reshape(2, 2)
10+
df = pd.DataFrame(foo)
11+
bar = np.zeros_like(df)
12+
print(bar)
13+
result = np.add(df, 1, out=bar)
14+
print(bar)
15+
16+
expected = np.array([[2, 3], [4, 5]])
17+
np.testing.assert_equal(bar, expected)

0 commit comments

Comments
 (0)