[Python] Python Pandas - read date column as string

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I have some data in an excel file and I read it using pandas read_excel method. However I want to read the entire data in all columns as strings including the date column.

    The problem is that I want to leave the date column in its original format as string. For example, I have '31.01.2017' in the excel and it is formatted as date and I want to have '31.01.2017' in my data frame.

    I thought using dytpes parameter of read_excel with dtype=str was the correct approach. But pandas then reads the date column as datetime and then converts it to string. So at the end I always have '2017-01-31 00:00:00' in my data frame.

    Is there any way to do this?

    Continue reading...

Compartilhe esta Página