[英]How can I import specific columns from csv file to python?
I recommend using the pandas library for handling the csv.我建议使用 pandas 库来处理 csv。
You can use read_csv()
to skip/select rows based on a conditional format.您可以使用read_csv()
根据条件格式跳过/选择行。
Here is a link with a step-by-step guide on how to do this:这是一个链接,其中包含有关如何执行此操作的分步指南:
https://datascientyst.com/read_csv-skip-rows-condition-values-pandas/amp/ https://datascientyst.com/read_csv-skip-rows-condition-values-pandas/amp/
Alternatively, you can import the entire .csv
file and then delete certain rows based on a condition, as seen in the link below:或者,您可以导入整个.csv
文件,然后根据条件删除某些行,如下面的链接所示:
https://towardsdatascience.com/delete-row-from-pandas-dataframes-based-on-column-value-4b18bb1eb602 https://towardsdatascience.com/delete-row-from-pandas-dataframes-based-on-column-value-4b18bb1eb602
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.