
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
KeyError: "['candle_date_time_utc', 'timestamp', 'first_day_of_period'] not found in axis"
자꾸 이런 에러가 뜨는데 84퍼센트까지 잘 진행하다가 자꾸 이런 에러가 뜨니까 왜 이러는지 모르겠어요. 없었으면 처음부터 에러가 떠야지 20분 실행중에 자꾸 이렇게 에러가 뜨네요...

작성한 코드 및 에러 메세지
# 1
import os
import time
import requests
import pandas as pd
import json
url = "https://api.upbit.com/v1/market/all?isDetails=true"
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers)
market_code_df = pd.DataFrame(json.loads(response.text))
datetimes = []
for year in range(2018,2025):
datetimes.append(f"{year}-01-01T00%3A00%3A00%2B09%3A00")
def get_coin(market_code, datetimes):
headers = {"accept": "application/json"}
dfs = []
for datetime in datetimes:
url = f"https://api.upbit.com/v1/candles/weeks?market={market_code}&to={datetime}&count=53"
response = requests.get(url, headers=headers)
dfs.append(pd.DataFrame(json.loads(response.text)))
time.sleep(0.034)
df = pd.concat(dfs)
df = df.drop(columns=["candle_date_time_utc", "timestamp", "first_day_of_period"])
df.columns = [
"market",
"datetime",
"open",
"high",
"low",
"close",
"trade_price",
"trade_volume"
]
df["change_rate"] = (df["close"] - df["open"]) / df["open"] * 100
df = df.sort_values(by="datetime").reset_index(drop=True)
df = df.drop_duplicates()
return df
from tqdm import tqdm
base_path = "/content/drive/MyDrive/coin_data/weeks"
for market_code in tqdm(market_code_df["market"]):
df = get_coin(market_code, datetimes)
if len(df) >= 730:
df.to_csv(base_path + f"/{market_code}.csv", index=False)
file_list = os.listdir(base_path)
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
