loc
loc is primarily label based; when two arguments are used, you use column headers and row indexes to select the data you want. loc can also take an integer as a row or column number.
df.loc[0,’Artist’]: ‘Michael Jackson’
iloc
iloc is integer-based. You use column numbers and row numbers to get rows or columns at particular positions in the data frame.
iloc slicing
z=df.iloc[0:2,0:3]
Import pandas
Pandas have a list of functions including: read_csv() Series() DataFrame values
import pandas as pd
csv_path = “a.csv”
df = pd.read_csv(csv_path)
df.head() examines the frist 5 rows of data frame.
create new dataframe consisting of one column
x=df[[‘Length’]]
create multiple columns
y=df[[‘Artist’, ‘Length’, ‘Genre’]]