Unit - V Introduction To Pandas in Python
Unit - V Introduction To Pandas in Python
Faculty of Science,
Department of Computer Science
& I.T.
Subject Name: 21UFSDE309 Data Science Using Python
Name
Dhyey
Krishna
Kishan
Radha
Shyam
print(df)
Department of Computer Science & I.T.
Data Frames
Locate Row
As you can see from the result above, the DataFrame is
like a table with rows and columns.
Pandas use the loc attribute to return one or more
specified row(s)
Example
Return row 0:
#refer to the row index:
print(df.loc[0])
Department of Computer Science & I.T.
Data Frames
Named Indexes
With the index argument, you can name your own indexes.
Example
Add a list of names to give each row a name:
import pandas as pd
print(df)
Department of Computer Science & I.T.
Data Frames
Load Files Into a DataFrame
If your data sets are stored in a file, Pandas can load them
into a DataFrame.
Example
Load a comma separated file (CSV file) into a DataFrame:
import pandas as pd
df = pd.read_csv('data.csv')
print(df)
Department of Computer Science & I.T.