Is there a difference between read_table and read_csv in pandas?

前端 未结 3 1247
太阳男子
太阳男子 2021-02-13 11:59

I\'ve tested it and also checked the documentation with no visible differences.Either way i wanted to ask just in case.

Do you think that read_csv should be used only fo

3条回答
  •  不知归路
    2021-02-13 12:43

    The only difference is in fact the default value for the sep argument.

    read_csv uses sep=',', read_table uses sep='\t' and that's it.

    We can confirm this with the help of the inspect module by getting the signature parameters as ordered mappings.

    import inspect                                                                                                     
    import pandas as pd                                                                                                
    
    params_csv = inspect.signature(pd.read_csv).parameters                                                                
    params_table = inspect.signature(pd.read_table).parameters
    

    There are only two elements in the symmetric difference of the parameters which both correspond to the sep argument and its different default value for the two functions.

    >>> params_csv.items() ^ params_table.items()                                                                                
    {('sep', ), ('sep', )}
    

提交回复
热议问题