# Useful codes for exam

## read and summary

```python
df1=pd.read_csv('manu1(1).csv')
df1.describe()
```

## missing values

```python
df2=pd.read_csv('manu2(1).csv')
df2['material'].fillna('C',inplace=True)
```

## replace a column and caculate mean by a group(column)

```python
df2['ksize']=df2['ksize']+1
df2.groupby(['material']).mean()
```

## merge dataframe by a column

```python
df3 = pd.merge(df1, df2, on='ID')
```

## concat dataframe by rows

```python
df4=pd.read_csv('manu3(1).csv')
df5=pd.concat([df3,df4])
```

## select rows by column value

```python
df.loc[df['material'] == material]
```

## split training and testing

```python
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
```
