简体   繁体   English

使用 Pandas、python 迭代行 csv 文件

[英]Iterate row csv file using pandas, python

How can I iterate over my second row of an csv file using pandas?如何使用 Pandas 遍历 csv 文件的第二行? I have a csv file like我有一个像

;Fund Code;Date;Security ID

0;BOOY;10/23/2015;906

1;BOOY;10/23/2015;932

1;BOOY;10/23/2015;931

I want to print the following:我想打印以下内容:

0
BODY
10/23/2015
906

I am not sure that this is what you want.我不确定这是你想要的。 It seems you want to print only the first line of your csv (excluding the header).您似乎只想打印 csv 的第一行(不包括标题)。 If so, this is as simple as:如果是这样,这很简单:

import pandas 
from pandas import *

df = pd.read(path_to_your_file)

df.head(1) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM