일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 파이썬
- django
- matplotlib
- hive
- string
- c#
- math
- Google Excel
- SQL
- google apps script
- PySpark
- Kotlin
- Tkinter
- gas
- PANDAS
- Github
- Mac
- PostgreSQL
- numpy
- Redshift
- Apache
- GIT
- Google Spreadsheet
- Excel
- dataframe
- list
- Python
- array
- Java
- Today
- Total
목록to_list (2)
달나라 노트
numpy의 tolist method는 array를 python의 list로 바꿔줍니다. 변경할 때 array의 차원을 그대로 유지합니다. 2차원 array에 tolist를 적용시키면 list속에 다른 list가 있는 2차원 list의 형태로 반환해준다는 의미이죠. 아래 예시들을 봅시다. import numpy as np arr_test = np.array( [1, 2, 3, 4, 5] # 1차 array ) list_test = arr_test.tolist() print(arr_test) print(list_test) -- Result [1 2 3 4 5] [1, 2, 3, 4, 5] import numpy as np arr_test = np.array( [ # 1차 array [1, 2, 3, 4, ..
Pandas에서 제공하는 to_list method는 Series에 적용할 수 있으며 적용된 Series를 list 형태로 변환해주는 역할을 합니다. import pandas as pd dict_main = { 'col1': [1, 2, 3, 4, 5, 6], 'col2': ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta'] } df_main = pd.DataFrame(dict_main) print(df_main) list_col2 = df_main.loc[:, 'col2'].to_list() print(list_col2) list_col2 = list(df_main.loc[:, 'col2']) print(list_col2) -- Result col1 col..