Skip to content

Commit 37923d3

Browse files
Arize AI Devsfjcasti1
authored andcommitted
Project import generated by Copybara.
GitOrigin-RevId: 9809006adfe29e04abb6d1bce72991575deee8e3
1 parent cc0bb50 commit 37923d3

12 files changed

Lines changed: 799 additions & 40 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [8.1.0](https://github.com/Arize-ai/arize/compare/arize-python-sdk/v8.0.2...arize-python-sdk/v8.1.0) (2026-02-09)
4+
5+
6+
### 🎁 New Features
7+
8+
* **responses:** support one-level expansion in `to_df` methods ([#62391](https://github.com/Arize-ai/arize/issues/62391)) ([899edeb](https://github.com/Arize-ai/arize/commit/899edeba53d7c1212127f0673af7c77af0820a87))
9+
* **regions:** add `Region.list_regions` class method
10+
11+
### 🐛 Bug Fixes
12+
13+
* **config:** add max_val constraint to stream_max_workers
14+
315
## [8.0.2](https://github.com/Arize-ai/arize/compare/arize-python-sdk/v8.0.1...arize-python-sdk/v8.0.2) (2026-02-04)
416

517

docs/source/_static/switcher.json

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"url": "https://arize-client-python.readthedocs.io/en/latest/",
55
"preferred": true
66
},
7+
{
8+
"version": "v8.1.0",
9+
"url": "https://arize-client-python.readthedocs.io/en/v8.1.0/"
10+
},
711
{
812
"version": "v8.0.0",
913
"url": "https://arize-client-python.readthedocs.io/en/v8.0.0/"
@@ -87,37 +91,5 @@
8791
{
8892
"version": "v7.33.0",
8993
"url": "https://arize-client-python.readthedocs.io/en/v7.33.0/"
90-
},
91-
{
92-
"version": "v7.32.0",
93-
"url": "https://arize-client-python.readthedocs.io/en/v7.32.0/"
94-
},
95-
{
96-
"version": "v7.31.0",
97-
"url": "https://arize-client-python.readthedocs.io/en/v7.31.0/"
98-
},
99-
{
100-
"version": "v7.30.0",
101-
"url": "https://arize-client-python.readthedocs.io/en/v7.30.0/"
102-
},
103-
{
104-
"version": "v7.29.0",
105-
"url": "https://arize-client-python.readthedocs.io/en/v7.29.0/"
106-
},
107-
{
108-
"version": "v7.28.0",
109-
"url": "https://arize-client-python.readthedocs.io/en/v7.28.0/"
110-
},
111-
{
112-
"version": "v7.27.1",
113-
"url": "https://arize-client-python.readthedocs.io/en/v7.27.1/"
114-
},
115-
{
116-
"version": "v7.26.0",
117-
"url": "https://arize-client-python.readthedocs.io/en/v7.26.0/"
118-
},
119-
{
120-
"version": "v7.25.0",
121-
"url": "https://arize-client-python.readthedocs.io/en/v7.25.0/"
12294
}
12395
]

src/arize/__init__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def to_df(
3737
exclude_none: str | bool = False,
3838
json_normalize: bool = False,
3939
convert_dtypes: bool = True,
40+
expand_field: str = "additional_properties",
41+
expand_prefix: str = "",
4042
) -> object:
4143
"""Convert a list of objects to a :class:`pandas.DataFrame`.
4244
@@ -55,6 +57,9 @@ def to_df(
5557
- True: alias for "all"
5658
json_normalize (bool): If True, flatten nested dicts via `pandas.json_normalize`.
5759
convert_dtypes (bool): If True, call `DataFrame.convert_dtypes()` at the end.
60+
expand_field (str): If set, look for this field in each row and
61+
expand its keys into top-level columns.
62+
expand_prefix (str): If set, prefix expanded column names with this string.
5863
5964
Returns:
6065
pandas.DataFrame: The converted DataFrame.
@@ -66,15 +71,26 @@ def to_df(
6671
rows = []
6772
for it in items:
6873
if hasattr(it, "model_dump"): # Pydantic v2 object
69-
rows.append(it.model_dump(by_alias=by_alias))
70-
74+
row = it.model_dump(by_alias=by_alias)
7175
elif isinstance(it, Mapping): # Plain mapping
72-
rows.append(it)
76+
row = dict(it) # Make a copy to avoid mutating the original
7377
else:
7478
raise ValueError(
7579
f"Cannot convert item of type {type(it)} to DataFrame row"
7680
)
7781

82+
# --- one-level expansion (no recursion) ---
83+
if expand_field and isinstance(row.get(expand_field), Mapping):
84+
nested = dict(row.pop(expand_field))
85+
if expand_prefix:
86+
nested = {
87+
f"{expand_prefix}{k}": v for k, v in nested.items()
88+
}
89+
# nested keys win only if you want them to; swap order if not
90+
row = {**row, **nested}
91+
92+
rows.append(row)
93+
7894
df = (
7995
pd.json_normalize(rows, sep=".")
8096
if json_normalize

0 commit comments

Comments
 (0)