| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- array
- SQL
- gas
- google apps script
- Python
- Tkinter
- hive
- math
- PySpark
- Excel
- Google Excel
- numpy
- c#
- Presto
- Google Spreadsheet
- Apache
- Kotlin
- dataframe
- GIT
- PANDAS
- list
- matplotlib
- Redshift
- string
- Github
- Java
- django
- 파이썬
- PostgreSQL
- Today
- Total
목록Python (396)
달나라 노트
DataFrame의 memory 사용량을 보는 대표적인 방법 두가지를 알아보겠습니다. 1. info() method 이용 import pandas as pddf_1 = pd.DataFrame({ 'col1': [1, 1, 2, 2, 2, 3, 3, 3], 'col2': [4, 5, 6, 1, 8, 3, 5, 1], 'valid_yn': [1, 1, 1, 1, 1, 0, 0, 0],})# 주의사항: 데이터가 아주 클 경우, pandas는 성능을 위해 메모리 사용량을 추정치로만 보여줄 수 있습니다.# 이때는 아래처럼 memory_usage='deep' 옵션을 추가해야 정확한 memory 사용량을 보여줍니다.print(df_1.info(memory_usage='deep'))-- ResultR..
Python을 다룰 때 가상환경(Virtual Environment)을 다루는 경우는 매우 흔합니다. 이번에는 (anaconda python이 아닌) 일반 Python을 사용할 때 가상환경을 어떻게 관리할 수 있는지를 알아봅시다. 일단 현재 Python이 설치되어 있는지, 설치되어있다면 그 경로가 어디인지 봅시다. (base) ~~% which -a python/opt/anaconda3/bin/python3/usr/local/bin/python3/usr/bin/python3 which -a python 명령어를 이용하여 현재 설치된 python의 경로와 종류를 파악합니다.(이는 각자의 환경마다 다를 수 있으며 python은 이미 설치되어있다고 가정합니다.) 원하는 Python을 선택하여 가상환경..
pathlib에서 suffix 속성을 이용하면 파일의 확장자를 받을 수 있습니다. from pathlib import Pathdir_path = '/Users/Documents/code/pythonProject/h_2.py'# Create a Path objectobj_path = Path(dir_path)# Get extension through suffix attributeextension = obj_path.suffix# Show extensionprint(extension)-- Result.py - obj_path = Path(dir_path)먼저 Path를 통해 특정 directory에 존재하는 파일에 대한 object를 만듭니다.그러면 이 object에는 파일에 대한 다양한 정보가 담겨있게 ..
os.path.isfile()은 주어진 경로가 파일인지 아닌지를 return합니다. os.path.isfile(directory) 사용법은 위와 같습니다.directory가 파일이라면 True를 return합니다.directory가 파일이 아니라면 False를 return합니다. import ostarget_dir = '/Users/Documents/code/pythonProject/gemini_test.py' # 1bool_file_yn = os.path.isfile(target_dir) # 2print(bool_file_yn)-- ResultTrue 1. 체크할 directory를 준비합니다. 2. os.path.isfile() method를 이용하여 directory의 파일 여부를 체크합니다..
