print last n rows of dataframe
df1.tail(n)
Returns the first n rows
# Returns the first n rows
df.head()
# Row(age=2, name=u'Alicz')
df.head(1)
# [Row(age=2, name=u'Alice')]
how to show n rows with pandas python
import pandas as pd
#initialize a dataframe
df = pd.DataFrame(
[[21, 72, 67],
[23, 78, 62],
[32, 74, 56],
[73, 88, 67],
[32, 74, 56],
[43, 78, 69],
[32, 74, 54],
[52, 54, 76]],
columns=['a', 'b', 'c'])
#get first 3 rows
n=3
df1 = df.head(n)
#print the dataframe
print(df1)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us