Skip to content

Commit c470b2e

Browse files
committed
fix: EDGAR 컬럼명 DART 통일 — account→snakeId, category→분류, metric→계정명
DART와 EDGAR Company가 동일한 컬럼 구조를 반환하도록 통일. - EDGAR IS/BS/CF: account → snakeId + 계정명 컬럼 추가 - EDGAR ratios: category → 분류, metric → 계정명 - 테스트 업데이트 (test_show_ratios_returns_data)
1 parent bcff900 commit c470b2e

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/dartlab/providers/edgar/_finance_accessor.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,15 @@ def _stmtDf(self, stmtKey: str) -> pl.DataFrame | None:
4848
self._company._cache[cacheKey] = None
4949
return None
5050

51+
from dartlab.core.finance.labels import get_korean_labels
52+
53+
krLabels = get_korean_labels()
5154
rows = []
5255
for snakeId, values in stmtData.items():
53-
row: dict[str, Any] = {"account": snakeId}
56+
row: dict[str, Any] = {
57+
"snakeId": snakeId,
58+
"계정명": krLabels.get(snakeId, snakeId),
59+
}
5460
for i, year in enumerate(years):
5561
row[str(year)] = values[i] if i < len(values) else None
5662
rows.append(row)
@@ -61,8 +67,8 @@ def _stmtDf(self, stmtKey: str) -> pl.DataFrame | None:
6167

6268
result = pl.DataFrame(rows)
6369
# 기간 컬럼 역순 정렬
64-
periodCols = [c for c in result.columns if c != "account"]
65-
result = result.select(["account"] + periodCols[::-1])
70+
periodCols = [c for c in result.columns if c not in ("snakeId", "계정명")]
71+
result = result.select(["snakeId", "계정명"] + periodCols[::-1])
6672
self._company._cache[cacheKey] = result
6773
return result
6874

src/dartlab/providers/edgar/company.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ def _ratioSeriesToDataFrame(
354354
if not values or not any(v is not None for v in values):
355355
continue
356356
row: dict[str, Any] = {
357-
"category": _RATIO_CATEGORY_LABELS.get(category, category),
358-
"metric": _RATIO_FIELD_LABELS.get(fieldName, fieldName),
357+
"분류": _RATIO_CATEGORY_LABELS.get(category, category),
358+
"계정명": _RATIO_FIELD_LABELS.get(fieldName, fieldName),
359359
"_field": fieldName,
360360
}
361361
for idx, year in enumerate(years):
@@ -2599,10 +2599,10 @@ def capital(self, view: str | None = None) -> pl.DataFrame | None:
25992599
if pcols:
26002600
latest = pcols[0]
26012601
for row in equity.iter_rows(named=True):
2602-
rows[0][row["account"]] = row.get(latest)
2602+
rows[0][row["snakeId"]] = row.get(latest)
26032603
if divs is not None:
26042604
for row in divs.iter_rows(named=True):
2605-
rows[0][row["account"]] = row.get(latest)
2605+
rows[0][row["snakeId"]] = row.get(latest)
26062606
return pl.DataFrame(rows)
26072607

26082608
def debt(self, view: str | None = None) -> pl.DataFrame | None:
@@ -2637,5 +2637,5 @@ def debt(self, view: str | None = None) -> pl.DataFrame | None:
26372637
if pcols:
26382638
latest = pcols[0]
26392639
for row in debt_accts.iter_rows(named=True):
2640-
rows[0][row["account"]] = row.get(latest)
2640+
rows[0][row["snakeId"]] = row.get(latest)
26412641
return pl.DataFrame(rows)

tests/test_edgarDocs_foundation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,11 +1288,12 @@ def test_show_ratios_returns_data(self):
12881288
# ratios는 블록 1개 → auto unwrap으로 바로 데이터 반환 (DART 정합)
12891289
df = c.show("ratios")
12901290
assert isinstance(df, pl.DataFrame)
1291-
assert "category" in df.columns
1291+
assert "분류" in df.columns
1292+
assert "계정명" in df.columns
12921293
# block=0 명시도 동일 결과
12931294
df2 = c.show("ratios", 0)
12941295
assert isinstance(df2, pl.DataFrame)
1295-
assert "category" in df2.columns
1296+
assert "분류" in df2.columns
12961297

12971298
def test_show_docs_topic_returns_dataframe(self):
12981299
from dartlab.providers.edgar.company import Company

0 commit comments

Comments
 (0)