일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- PyQt5
- swift
- node.js
- sqlite
- 맛집
- flutter
- 라즈베리파이
- 유니티
- Unity
- 함수
- PER
- ASP
- PyQt
- tensorflow
- port
- 다이어트
- MS-SQL
- 리눅스
- javascript
- 날짜
- MySQL
- Excel
- GIT
- python
- mssql
- urllib
- ubuntu
- IOS
- Linux
- pandas
목록2025/07 (15)
아미(아름다운미소)
import tracebacktry: # 에러 유발 코드 (예시: 0으로 나누기) x = 1 / 0except Exception as e: print("❗ 에러 발생:", str(e)) traceback.print_exc() # 전체 에러 트레이스 출력import numpy as np# 인덱스가 다른 위치 찾기diff_indices = np.where(df.index != df1.index)[0]# 결과 출력print("인덱스가 다른 위치:", diff_indices)print("\n--- df의 인덱스 ---")print(df.index[diff_indices])print("\n--- df1의 인덱스 ---")print(df1.index[diff_indices])
first_date = df.get('날짜열', pd.Series([pd.NaT])).iloc[0]
import pandas as pd# 예시: 둘 다 빈 DataFrame이지만 컬럼이 다름df1 = pd.DataFrame(columns=['a', 'b'])df2 = pd.DataFrame(columns=['b', 'c'])# 👉 모든 컬럼의 합집합 구하기all_columns = sorted(set(df1.columns).union(set(df2.columns)))# 👉 컬럼 맞춰주기 (reindex로 없으면 NaN 채움)df1 = df1.reindex(columns=all_columns)df2 = df2.reindex(columns=all_columns)# 👉 concatresult = pd.concat([df1, df2], ignore_index=True)print(result)
import pandas as pddf = pd.DataFrame({ 'a': ['2024-01-01', '2024-01-02', None]})# 문자열 → datetime으로 변환df['a'] = pd.to_datetime(df['a'], errors='coerce')# 첫 번째 값 가져오기first_val = df['a'].iloc[0] # 또는 .iat[0]print(first_val)
import requestsurl = "https://your-api-url.com/stock/signal"params = { "stock_name": "극동유화", "max_news": 50}headers = { "Authorization": "Bearer YOUR_API_KEY" # 필요 시}response = requests.post(url, json=params, headers=headers)# 응답값이 JSON이면if response.status_code == 200: res = response.json() signal = res.get("signal") # 또는 res["signal"] print("📈 Signal:", signal)else: prin..