Plus sign lost when reading excel sheet with pandas

678 Views Asked by At

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)
2

There are 2 best solutions below

0
On BEST ANSWER

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

0
On

Refer documentation to handle the datatypes here enter image description here