Answers for "print n th row of a dataframe"

0

python print every row of dataframe

df = pandas.read_csv("data.csv")
pandas.set_option('display.max_rows', df.shape[0]+1)
print(df)
Posted by: Guest on February-13-2021
0

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)
Posted by: Guest on September-04-2021

Code answers related to "print n th row of a dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language