Skip to main content

How to Send a dataframe_split Request to an MLflow Model Server

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

dataframe_split is the JSON layout MLflow's model server reads most directly: the column names once, then each row's values in the same order, just as pandas splits a DataFrame. This guide builds one from a DataFrame, sends it to a served model with curl and PowerShell, and reads the answer, with real output from MLflow 3.18.0.

Syntax​

Syntax
{"dataframe_split": {"columns": [COLUMN, ...], "data": [[VALUE, ...], ...]}}
PartWhat it means
columnsThe input column names, as in the model's signature
dataOne list per row, with its values in the same order as columns
indexOptional: a label per row; the server doesn't need it

MLflow's guide to the inference server describes it as "Pandas DataFrames in the split orientation", made with pandas_df.to_dict(orient="split"). It's sent with Content-Type: application/json to /invocations.

Prerequisites​

  • An MLflow tracking server at http://127.0.0.1:8080, such as mlflow server --port 8080.
  • mlflow and scikit-learn in your project, for example with uv add mlflow scikit-learn pandas.

Step 1: Log a Model and Save Two Rows​

The example trains a linear regression on scikit-learn's California housing data, which predicts a district's median house value, in units of $100,000, from eight numbers such as the median income. It logs the model and saves the first two districts as a request:

The log_house_model.py script in a macOS-style code window: a LinearRegression trained on California housing, logged with an input example, and the first two rows written to two_districts.json with to_dict(orient="split", index=False).

log_house_model.py
import json

import mlflow
from sklearn.datasets import fetch_california_housing
from sklearn.linear_model import LinearRegression

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("split-request-example")

X, y = fetch_california_housing(return_X_y=True, as_frame=True)
model = LinearRegression().fit(X, y)
with mlflow.start_run():
info = mlflow.sklearn.log_model(model, name="model", input_example=X.head(3))
print("Model URI:", info.model_uri)

# Two districts in the dataframe_split layout
with open("two_districts.json", "w") as f:
json.dump({"dataframe_split": X.head(2).to_dict(orient="split", index=False)}, f, indent=2)
Terminal
uv run python log_house_model.py
Output (last line)
Model URI: models:/m-af53e58e36974d81ad2986cc270a820b

to_dict(orient="split", index=False) turns the two rows into a dictionary with columns and data, and json.dump writes it. The file:

two_districts.json
{
"dataframe_split": {
"columns": [
"MedInc",
"HouseAge",
"AveRooms",
"AveBedrms",
"Population",
"AveOccup",
"Latitude",
"Longitude"
],
"data": [
[
8.3252,
41.0,
6.984126984126984,
1.0238095238095237,
322.0,
2.5555555555555554,
37.88,
-122.23
],
[
8.3014,
21.0,
6.238137082601054,
0.9718804920913884,
2401.0,
2.109841827768014,
37.86,
-122.22
]
]
}
}

Step 2: Serve the Model​

Terminal 2
export MLFLOW_TRACKING_URI=http://127.0.0.1:8080
uv run mlflow models serve -m "models:/m-af53e58e36974d81ad2986cc270a820b" -p 5001 --env-manager uv

Wait for Uvicorn running on http://127.0.0.1:5001.

Step 3: Send the Request​

In another terminal, send the file to /invocations:

Terminal 3
curl http://127.0.0.1:5001/invocations -H "Content-Type: application/json" --data @two_districts.json
Output
{"predictions": [4.1316498270767426, 3.9766064387043514]}

curl's output in a terminal: predictions 4.1316498270767426 and 3.9766064387043514 as JSON.

One prediction per row, in order: about $413,000 for the first district and $398,000 for the second. PowerShell rounds the numbers when it prints them.

Common Mistakes​

MistakeWhat happensDo this instead
The JSON without the dataframe_split key, {"columns": ..., "data": ...}400: The input must be a JSON dictionary with exactly one of the input fieldsWrap it in {"dataframe_split": ...}
A missing column400 with Model is missing inputsSend every column in the signature

Troubleshooting​

SymptomLikely causeFix
Object of type int64 is not JSON serializable when you build the request with json.dumpsValues taken from NumPy directly, not through to_dictBuild it with DataFrame.to_dict(orient="split", index=False)
415 Unsupported Media TypeThe request has no Content-Type: application/jsonAdd the header

FAQ​

Do whole numbers need a decimal point?​

No: the server turns each value into the type the model's signature asks for. When I sent another model's rows with whole numbers, such as 3 instead of 3.0, the predictions were the same.

Why dataframe_split and not dataframe_records?​

dataframe_split writes each column name once and keeps the order. dataframe_records repeats the names in every row: How to Send a dataframe_records Request to an MLflow Model Server.

Conclusion​

Two California districts, written with to_dict(orient="split", index=False) as columns plus one list of values per row and wrapped in {"dataframe_split": ...}, came back from the model server as two predictions, 4.13 and 3.98, in the same order.

Additional Resources​