일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 날짜
- PER
- 맛집
- MySQL
- javascript
- 라즈베리파이
- MS-SQL
- PyQt
- 다이어트
- GIT
- Linux
- Excel
- node.js
- python
- swift
- urllib
- port
- flutter
- pandas
- IOS
- sqlite
- 함수
- ASP
- 리눅스
- PyQt5
- tensorflow
- ubuntu
- Unity
- 유니티
- mssql
목록랭귀지 (579)
아미(아름다운미소)
import pandas as pddef add_blank_category_or_fillna(series): try: if pd.api.types.is_categorical_dtype(series): # ''가 이미 포함되어 있는지 확인 if '' not in series.cat.categories: return series.cat.add_categories(['']) else: return series else: return series.fillna('') except Exception as e: print(f"예외 발생: ..
import duckdb# DuckDB DB 파일에 연결 (없으면 생성됨)con = duckdb.connect("mydata.duckdb")# CSV 파일 읽어서 테이블로 저장con.execute("""CREATE TABLE my_table ASSELECT * FROM read_csv_auto('sample.csv')""")import pandas as pdimport duckdbdf = pd.read_csv("sample.csv")# DuckDB에 저장con = duckdb.connect("mydata.duckdb")con.register("df_view", df)# DataFrame을 테이블로 저장con.execute("CREATE TABLE my_table AS SELECT * FROM df_vie..
import osimport timefrom openpyxl import load_workbooktemp_path = "temp.xlsx"try: wb = load_workbook(temp_path) ws = wb.active # ... 작업 ...finally: # 임시 파일 닫고 삭제 (삭제 실패 시 재시도) try: wb.close() except: pass max_retries = 5 retry_delay = 0.5 # 초 for attempt in range(1, max_retries + 1): try: os.remove(temp_path) print(f"✅ 임시 파일 ..
# 1. 현재 어떤 브랜치에 있는지 확인git branch# 2. main 브랜치로 이동git checkout main# 3. 최신 상태로 업데이트 (필요 시)git pull origin main# 4. a 브랜치를 main에 머지git merge a# 5. 원격 저장소에 반영git push origin main
if text is not None: text = text.replace("a", "b")else: text = "" # 또는 기본값 설정
from pynput import keyboard, mousefrom pynput.keyboard import Controller, Keyimport threadingimport timefrom datetime import datetimeimport ctypesimport os# ✅ 로그 저장 기본 디렉토리 (원하는 경로로 변경하세요)LOG_BASE_DIR = r"D:/logs"# 설정IDLE_TIME_LIMIT = 300 # 5분 이상 비활동 시CHECK_INTERVAL = 10 # 활동 체크 주기keyboard_controller = Controller()last_activity_time = time.time()# 로그 기록 함수def write_log(message): now = dat..
import numpy as npimport pandas as pdimport multiprocessing as mpfrom functools import partialdef process_chunk(df_chunk, conditions, choices, default): # 각 청크에 np.select 적용 result = np.select(conditions, choices, default=default) return pd.Series(result, index=df_chunk.index)def parallel_select(df, conditions, choices, default='default', num_processes=None): if num_processes is None..
cols = ['col1', 'col2', 'col3'] # category로 바꿀 컬럼 리스트df[cols] = df[cols].apply(lambda x: x.astype('category'))import pandas as pdimport numpy as np# 예시 데이터 생성df = pd.DataFrame({ 'col1': np.random.choice(['apple', 'banana', 'cherry'], 1_000_000), 'col2': np.random.choice(['red', 'green', 'blue'], 1_000_000), 'col3': np.random.choice(['small', 'medium', 'large'], 1_000_000)})# 🔍 메모리 사용량..
import pandas as pddf1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}, index=['x', 'y'])df2 = pd.DataFrame({'A': [5, 6], 'C': [7, 8]}, index=['x', 'y'])# Left join with drop=Falseresult = df1.join(df2.set_index('A', drop=False), how='left', # 명시적으로 left join 지정 lsuffix='_left', rsuffix='_right')print(result)
from concurrent.futures import ThreadPoolExecutorimport numpy as npimport pandas as pddef safe_parallel_merge(df1, df2, left_key, right_key=None, n_partitions=4, how='left'): """ 개선된 병렬 merge 함수 - 안정성 강화 버전 Parameters: - df1: 왼쪽 DataFrame - df2: 오른쪽 DataFrame - left_key: df1의 조인 키 (컬럼명 또는 컬럼 리스트) - right_key: df2의 조인 키 (None이면 left_key와 동일) - n_partitions: 분할 개수 - ..