Skip to content

Commit c48dd2e

Browse files
add code sample for pandas-dev#37343
1 parent 8fb8bf0 commit c48dd2e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

bisect/37343.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pandas as pd
2+
3+
print(pd.__version__)
4+
5+
6+
class SubclassedDataFrame2(pd.DataFrame):
7+
8+
# temporary properties
9+
_internal_names = pd.DataFrame._internal_names + ["internal_cache"]
10+
_internal_names_set = set(_internal_names)
11+
12+
# normal properties
13+
_metadata = ["added_property"]
14+
15+
@property
16+
def _constructor(self):
17+
return SubclassedDataFrame2
18+
19+
20+
df = SubclassedDataFrame2({"A": [1, 2, 3], "B": [1, 1, 2], "C": [7, 8, 9]})
21+
df.added_property = "hello"
22+
for i, d in df.groupby("B"):
23+
assert d.added_property == "hello"

0 commit comments

Comments
 (0)