Answer the question
In order to leave comments, you need to log in
Why don't some pandas.read_excel options work?
Probably a loser question, but something doesn't google the answers.
The parameters convert_float
, date_parser
and do not work parse_dates
.
convert_float=True
-- not all excel integer values are converted to integer values. The part remains floating point. For example, the value 10 in excel turns into 10.0 ... And you can see that in general there is an integer, but for some reason pandas did not convert. And other values that were convert_float=False
not converted with -- do indeed become intdate_parser
and parse_dates
- did not understand at all. Setting it parse_dates
to True or False does not change anything. In both cases, the dates are converted to integer values (sometimes with a negative sign, and convert_float
it doesn't even affect them). How to force to work function through date_parser
- did not understand.import pandas
from datetime import datetime
def date_format(date):
# return date.isoformat()
return 'TEST'
def main():
# ...
# ...
xls_imported = pandas.read_excel(args.XLS_FILE, sheet_name=4, na_values=None,
convert_float=True, mangle_dupe_cols=True,
date_parser=date_format, parse_dates=True)
Answer the question
In order to leave comments, you need to log in
convert_float
- in pandas, the type is the same for all values in a column - there is a value in the column that cannot be converted to int. Most often this happens when a value is missing in a column, because an empty value is a Numpy NaN of the float type.
parse_dates
- a list of numbers or names of columns that need to be parsed into a date is transmitted - individual columns or groups of columns, if the date is distributed over several.
date_parser
- the default parser works fine, although it greatly increases the data loading time. It makes sense to parse the dates separately after loading if the volume is large.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question