9951 explained code solutions for 126 technologies


python-pandasGet first N rows (head) from data frame


import pandas as pd

data = pd.DataFrame({
  'Phone': ['ip5', 'ip6', 'ip8', 'sms', 'xi'],
  'Phone Price': [204, 304, 404, 405, 305]
})

rows = data.head(3)ctrl + c
import pandas as pd

load Pandas module

pd.DataFrame

creates Pandas DataFrame object

.head(

returns first given amount of rows

(3)

return first 3 rows

rows

will contain selected rows