1. Data Extract
Code:
import pandas #use pandas
df=pandas.read_csv('/content/drive/MyDrive/파이썬/data/gapminder.tsv',sep='\t')
#Extract data at DIR
print(type(df)) #show class
print(df.columns) #show colums
print(df.head()) #show first row to five row
print(df.shape) #show (row x colum)
print(df.dtypes) #show data type for pandas
print(df.info) #look up
Result:

2. Subset
Code:
subset=df[['continent','country','year']] #handling specific column
print(subset.loc[[0,1,2]]) #show 0,1,2 row
print(subset.iloc[[0,1,2]]) #show 0,1,2 row
print(subset.loc[0:10]) #show 0 to ten row
print(subset.head(n=3)) #show third from the head
print(subset.tail(n=3)) #show third from the tail
Result:

'AI Library > Pandas' 카테고리의 다른 글
| Graph Type (0) | 2021.11.15 |
|---|---|
| Seaborn Library (0) | 2021.11.14 |
| Matplotlib (0) | 2021.11.14 |
| Anscombe's quartet (0) | 2021.11.14 |
| Setting for Pandas (0) | 2021.11.12 |