Search code examples
pythonexcelpandasexcel-reader

Plus sign lost when reading excel sheet with pandas


I have a list of phone numbers in an excel sheet, along with other information related to the phone numbers. The phone numbers can be from different countries, so they start with a + sign, followed by a country code (for example +1055592947). The string is stored in excel as '+1055592947 to make it appear as a string.

However, when I read the excel file, the plus sign is lost. How can I prevent this from happening?

df = pd.read_excel(data_file_location, index_col=0)

Solution

  • You can define that it is a string when reading the file as follows:

    pd.read_excel('Book.xlsx',dtype = {'colname': str})
    

    enter image description here