Skip to content
Muthupandian @muthugit
2022-01-05 2023-02-12

Load CSV without replacing empty value to nan

In pandas the usual pd.read_csv load the CSV and replacing empty values to nan. If that needs to be override, pandas has the boolean option keep_default_na. If it is False then the pandas won't apply nan on the data

Example

import pandas as pd
pd.read_csv("/tmp/data.csv", keep_default_na=False)

For more ref: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html