Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python : How can i iterate 3 row values from dataframe at a single time? And then again next 3 values at a single time?

I have a data frame –

Name  Rank
A     2
B     3
C     6
D     7
E     4
F     3
G     9
H     2
I     5

I want Rank Column 3 values at a time.
such as –

2
3
6

and Next again I want to Rank Column 3 values at a time.
such as –

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

3
6
7

and Next again I want to Rank Column 3 values at a time.
such as –

6
7
4

Like in this format,
you can use any way loop or any other way.
I don’t know how I can do this, please help me to find out the solution.

>Solution :

Let us do

[df.Rank.tolist()[x:x+3] for x in df.index[0:-2]]
[[2, 3, 6], [3, 6, 7], [6, 7, 4], [7, 4, 3], [4, 3, 9], [3, 9, 2], [9, 2, 5]]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading