a minute read (About 180 words)
[PYTHON]칼럼 내 특정 값을 가진 row만 가져오기
라이브러리 및 데이터 불러오기
1 2 3 4
|
iris_df = sns.load_dataset('iris') iris_df
|
|
sepal_length |
sepal_width |
petal_length |
petal_width |
species |
0 |
5.1 |
3.5 |
1.4 |
0.2 |
setosa |
1 |
4.9 |
3.0 |
1.4 |
0.2 |
setosa |
2 |
4.7 |
3.2 |
1.3 |
0.2 |
setosa |
3 |
4.6 |
3.1 |
1.5 |
0.2 |
setosa |
4 |
5.0 |
3.6 |
1.4 |
0.2 |
setosa |
... |
... |
... |
... |
... |
... |
145 |
6.7 |
3.0 |
5.2 |
2.3 |
virginica |
146 |
6.3 |
2.5 |
5.0 |
1.9 |
virginica |
147 |
6.5 |
3.0 |
5.2 |
2.0 |
virginica |
148 |
6.2 |
3.4 |
5.4 |
2.3 |
virginica |
149 |
5.9 |
3.0 |
5.1 |
1.8 |
virginica |
150 rows × 5 columns
여러개를 할 경우 | 로 구분하면 됩니다 (ex: setosa | virginica)
1 2
| iris_filtered = iris_df[iris_df['species'].str.contains('setosa|virginica')] iris_filtered
|
|
sepal_length |
sepal_width |
petal_length |
petal_width |
species |
0 |
5.1 |
3.5 |
1.4 |
0.2 |
setosa |
1 |
4.9 |
3.0 |
1.4 |
0.2 |
setosa |
2 |
4.7 |
3.2 |
1.3 |
0.2 |
setosa |
3 |
4.6 |
3.1 |
1.5 |
0.2 |
setosa |
4 |
5.0 |
3.6 |
1.4 |
0.2 |
setosa |
... |
... |
... |
... |
... |
... |
145 |
6.7 |
3.0 |
5.2 |
2.3 |
virginica |
146 |
6.3 |
2.5 |
5.0 |
1.9 |
virginica |
147 |
6.5 |
3.0 |
5.2 |
2.0 |
virginica |
148 |
6.2 |
3.4 |
5.4 |
2.3 |
virginica |
149 |
5.9 |
3.0 |
5.1 |
1.8 |
virginica |
100 rows × 5 columns
You need to set install_url
to use ShareThis. Please set it in _config.yml
.