I’m working with an Excel file and need to read its contents into a DataFrame. When I use pandas (with default engine), I can specify the data type of the columns to be strings, which works perfectly:
import pandas as pd
df = pd.read_excel(fp, dtype=str, nrows=10)
print(df[col])
This gives me a column with values like:
4200000000
However, when I use Calamine to read the same file, the values in the same column end up with a .0 suffix:
from calamine import CalamineWorkbook
wb = CalamineWorkbook.from_path(fp)
row_list = wb.get_sheet_by_name(wb.sheet_names[0]).to_python()
print(row_list)
This results in:
4200000000.0
How can I stop Calamine from auto-guessing the data types? In pandas, I would use dtype=str, but my version of pandas does not support Calamine as an engine, and I cannot update it.