Skip to content

Commit da88b15

Browse files
code sample for pandas-dev#48090
1 parent 704608e commit da88b15

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bisect/48090.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# REGR: ensure DataFrame.select_dtypes() returns a copy #48176
2+
3+
import pandas as pd
4+
from pandas import DataFrame
5+
6+
print(pd.__version__)
7+
8+
# https://github.com/pandas-dev/pandas/issues/48090
9+
# result of this method is not a view on the original dataframe
10+
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
11+
df_orig = df.copy()
12+
13+
result = df.select_dtypes(include=["number"])
14+
15+
result.iloc[0, 0] = 0
16+
17+
print(df)
18+
19+
pd.testing.assert_frame_equal(df, df_orig)

0 commit comments

Comments
 (0)