Python Forum
Pandas: .(head) Can I specify a range in head? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pandas: .(head) Can I specify a range in head? (/thread-26722.html)



Pandas: .(head) Can I specify a range in head? - eeps24 - May-11-2020

In pandas, is it possible to specify a range in head? for example say I want to view rows 10-20, is there something where I can do...

.head(10-20)


RE: Pandas: .(head) Can I specify a range in head? - buran - May-11-2020

print(df.iloc[10:21])
of course, don't forget index start at 0


RE: Pandas: .(head) Can I specify a range in head? - eeps24 - May-11-2020

this is what i have now...

sf.toPandas().head(20)

can you please help format what I should have?

Thank you


RE: Pandas: .(head) Can I specify a range in head? - buran - May-11-2020

post minimal reproducible example. I don't know what sf is? Probably sf.toPandas().iloc[10:21]
df common name for pandas.DataFrame


RE: Pandas: .(head) Can I specify a range in head? - eeps24 - May-11-2020

sorry about that. SF is the name of my data frame...its coming from pyspark and then I am moving the data in to pandas.

sf.toPandas().head(20)

Do you know who I would modify this line? Currently its giving me 20 rows but I would like to do within a range.

thank you


RE: Pandas: .(head) Can I specify a range in head? - buran - May-11-2020

(May-11-2020, 04:08 PM)buran Wrote: Probably sf.toPandas().iloc[10:21]



RE: Pandas: .(head) Can I specify a range in head? - eeps24 - May-11-2020

sorry please ignore my previous post.. I saw your code above.

(May-11-2020, 04:26 PM)buran Wrote:
(May-11-2020, 04:08 PM)buran Wrote: Probably sf.toPandas().iloc[10:21]

it worked thank you!!!