Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- MS-SQL
- Unity
- 날짜
- 리눅스
- flutter
- PER
- sqlite
- mssql
- 라즈베리파이
- Excel
- 함수
- swift
- PyQt5
- 다이어트
- python
- pandas
- IOS
- ASP
- ubuntu
- node.js
- Linux
- 맛집
- port
- MySQL
- 유니티
- tensorflow
- urllib
- PyQt
- javascript
- GIT
Archives
아미(아름다운미소)
numba 본문
import numpy as np
import pandas as pd
from numba import njit
@njit
def numba_select(condlist, choicelist, default=0):
output = np.full(condlist[0].shape, default)
for cond, choice in zip(reversed(condlist), reversed(choicelist)):
output = np.where(cond, choice, output)
return output # NumPy 배열 반환
# 예시 데이터
condlist = [np.array([True, False, False]), np.array([False, True, False])]
choicelist = [np.array([1, 1, 1]), np.array([2, 2, 2])]
# Numba 함수 실행
result_array = numba_select(condlist, choicelist, default=0)
# NumPy 배열 → Pandas DataFrame 변환
df = pd.DataFrame({"result": result_array})
print(df)
Comments