python CSV module vs Pandas

纵饮孤独 提交于 2020-12-15 07:32:14

问题


I am using pandas to read CSV file data, but the CSV module is also there to manage the CSV file.

so my questions are :-

what is the difference between these both?

what are the cons of using pandas over the CSV module?


回答1:


Based upon benchmarks

  • CSV is faster to load data for smaller datasets (< 1K rows)

  • Pandas is several times faster for larger datasets

Code to Generate Benchmarks

Benchmarks




回答2:


  1. csv is a built-in module but pandas not. if you want only reading csv file you should not install pandas because you must install it and increasing in dependencies of project is not a best practice.
  2. if you want to analyze data of csv file with pandas, pandas changes csv file to dataframe needed for manipulating data with pandas and you should not use csv module for these cases.
  3. if you have a big data or data with large volume you should consider libraries like numpy and pandas.



回答3:


Pandas is better then csv for managing data and doing operations on the data. CSV doesn't provide you with the scientific data manipulation tools that Pandas does.

If you are talking only about the part of reading the file it depends. You may simply google both modules online but generally I find it more comfortable to work with Pandas. it provides easier readability as well since printing there is better too.



来源:https://stackoverflow.com/questions/62139040/python-csv-module-vs-pandas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!