[Python] What's the difference between dtype and converters in pandas.read_csv?

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    pandas function read_csv() reads a .csv file. Its documentation is here

    According to documentation, we know:


    dtype : Type name or dict of column -> type, default None Data type for data or columns. E.g. {‘a’: np.float64, ‘b’: np.int32} (Unsupported with engine=’python’)
    ​

    and


    converters : dict, default None Dict of functions for converting values in certain columns. Keys can either be integers or column labels
    ​

    When using this function, I can call either pandas.read_csv('file',dtype=object) or pandas.read_csv('file',converters=object). Obviously, converter, its name can says that data type will be converted but I wonder the case of dtype?

    Continue reading...

Compartilhe esta Página