To import an excel sheet as a pandas DataFrame in python, with all values as string, you can use the read_excel
function of the pandas library.
main.py130 chars5 lines
The read_excel
function reads the excel sheet at the specified filepath and returns a DataFrame object. The dtype=str
parameter tells pandas to convert all values to string. If you don't specify this parameter, pandas will try to infer the datatype of each column, which may not always give you the desired outcome.
gistlibby LogSnag