Fixed: "Incompatible input types for column … Can not safely convert int64 to float64" in MLflow
My model refused its own kind of data: a CSV file of shopping sessions failed with Incompatible input types for column Administrative. Can not safely convert int64 to float64. The model's signature declares those columns as decimals, double, and pandas reads whole numbers from a CSV as 64-bit integers. MLflow converts several types on its own, but not 64-bit integers to doubles. Reading the signature's double columns as float64 fixed my own code; for MLflow's command line, sending JSON instead of CSV did.
What I Was Doing
I was building the predict command of the shopper model in Part 6 of the MLflow series, on MLflow 3.18.0 and pandas 3.1.1. The model was trained with its whole-number columns read as decimals, so its signature lists them as double. The command reads a CSV of sessions, checks it against the signature and predicts. Its first version read the file plainly:
sessions = pd.read_csv(args.input)
model = mlflow.pyfunc.load_model(args.model_uri)
try:
# The signature lists every column the model needs and its type. Checking first turns
# a bad file into one clear sentence instead of a failed prediction.
mlflow.models.validate_schema(sessions, model.metadata.get_input_schema())
The file was three sessions I made up, with whole numbers where the dataset has counts and codes:
Administrative,Administrative_Duration,Informational,Informational_Duration,ProductRelated,ProductRelated_Duration,BounceRates,ExitRates,PageValues,SpecialDay,Month,OperatingSystems,Browser,Region,TrafficType,VisitorType,Weekend
3,80.0,1,30.0,40,1500.0,0.0,0.01,25.0,0.0,Nov,2,2,1,2,Returning_Visitor,False
0,0.0,0,0.0,1,0.0,0.2,0.2,0.0,0.0,May,1,1,1,3,New_Visitor,True
1,20.0,0,0.0,12,300.0,0.01,0.03,0.0,0.0,Mar,2,2,3,1,Returning_Visitor,False
uv run predict --model-uri models:/m-a56a76fad37f4c4e886eaf465f57e322 --input examples/sessions.csv
What I Expected
A purchase probability for each of the three sessions.
What I Got
2026/11/21 13:45:05 ERROR shopper_purchase_prediction: examples/sessions.csv doesn't match the model's signature: Incompatible input types for column Administrative. Can not safely convert int64 to float64.

The same file, scored with MLflow's own command line and a later model from the same training, failed the same way:
uv run mlflow --env-file .env models predict -m models:/m-6e2a8bb07fc44b02843eca07c555586f -i examples/sessions.csv -t csv --env-manager local
Error: Incompatible input types for column Administrative. Can not safely convert int64 to float64.

What I Checked
MLflow's guide to signatures lists the conversions it makes on its own: "int → long # 32-bit to 64-bit integer", "int → double # Integer to float", "float → double". And among the rejected ones: "long → double # Potential precision loss".
What pandas made of the file. It read Administrative and the other whole-number columns as int64, a 64-bit integer: MLflow's "long".
MLflow's code. The check in mlflow/models/utils.py allows integers to become doubles only when they're at most 6 bytes wide, with one exception: a 64-bit column holding nothing but 0, 1 or missing values. That exception is why a column of zeros passed in an earlier test of mine, and why the real data didn't.
Why It Happens
A double has 53 bits of precision (Python's floating-point guide: "IEEE 754 binary64 values contain 53 bits of precision"), while a 64-bit integer uses 64, so some large integers can't be represented exactly as doubles. MLflow therefore refuses to convert 64-bit integers to doubles. A CSV file doesn't say which columns are decimals, so pandas picks int64 for any column of whole numbers, and the signature's double columns get int64 data. JSON input doesn't have this problem: MLflow parses it with the model's signature in hand.
The Fix
Read every column the signature declares as double as float64, taking the list from the model itself:

model = mlflow.pyfunc.load_model(args.model_uri)
schema = model.metadata.get_input_schema()
# A CSV file doesn't say which numbers are decimals, so pandas reads whole numbers as
# 64-bit integers, which MLflow won't turn into the doubles the signature asks for.
# Read those columns as decimals from the start.
decimals = {
column.name: "float64" for column in schema.inputs if column.type == DataType.double
}
sessions = pd.read_csv(args.input, dtype=decimals)
DataType comes from mlflow.types. For MLflow's command line, which reads the CSV itself, send the rows as JSON instead, in the dataframe_split layout of the model's serving_input_example.json.
After the Fix
The command, writing its results to a file this time:
uv run predict --model-uri models:/m-6e2a8bb07fc44b02843eca07c555586f --input examples/sessions.csv --output scored.csv
2026/11/21 15:00:03 INFO shopper_purchase_prediction: Wrote 3 scored sessions to scored.csv

And the command line, with the same three sessions as JSON, sessions.json:
uv run mlflow --env-file .env models predict -m models:/m-6e2a8bb07fc44b02843eca07c555586f -i sessions.json -t json --env-manager local
{"predictions": [[0.18206545331405966, 0.8179345466859403], [0.9994173242880812, 0.0005826757119188792], [0.99863978394165, 0.0013602160583500364]]}

The JSON held the same whole numbers, and passed.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Training on integer columns to avoid the error | The signature says long, and a missing value is refused instead | Keep double, and read input as float64 |
| Testing the conversion with a column of zeros | It passes, by MLflow's 0-or-1 exception, and hides the problem | Test with real values |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Can not safely convert int64 to float64 from mlflow models predict -t csv | The CLI reads the CSV without the signature's types | Send JSON with -t json |
| The same error from your own code | pd.read_csv without dtype | Read the signature's double columns as float64 |
Can not safely convert float64 to int64 | The opposite: decimals for a long column | Make the column whole numbers, or log the model with double |
FAQ
Why does MLflow call it long?
In MLflow's types, int is a 32-bit integer and long a 64-bit one; its guide: "int → long # 32-bit to 64-bit integer". pandas' int64 is 64-bit, so it's a long.
Does the model care whether the numbers are 3 or 3.0?
No: the model was trained on these columns as decimals, and 3.0 is exactly 3.
Conclusion
The signature asked for double and pandas gave int64, a conversion MLflow refuses for loss of precision. Reading the signature's double columns as float64 let my command score the file, and JSON input let MLflow's command line do the same.
Additional Resources
- Model Signatures and Input Examples — the safe and unsafe conversions.
- pandas.read_csv — the
dtypeoption.
