CSV·자료사전·날짜·단위·인코딩CSV, dictionaries, dates, units and encodings
실제 저장 바이트에서 의미를 보존한 관측표까지From actual stored bytes to observations with preserved meaning
실습 6종 · 풀이 포함 연습문제 60개6 labs · 60 exercises with solutions
기초Foundations
1. 파일을 열었다는 말에는 여러 단계가 있다1. Opening a file involves several distinct steps
표처럼 보이는 파일을 열었는데 모든 값이 한 열에 들어갑니다. 한글은 깨지고 날짜는 다른 달로 바뀝니다. 오류 없이 읽혔더라도 우리가 의도한 관측표라는 보장은 없습니다. 이 장은 바이트→문자→행과 열→자료형→단위·시점 해석을 차례로 점검합니다.
작은 가정 CSV로 시작한 뒤 실제 BIS 분기 지수 180개, UCI 고객 3,150행, 레드 와인 1,599행을 읽습니다. 고객의 요금 수준 코드가 통화 금액인지, 분기 시작 날짜가 실제 측정 시각인지, 와인 열 이름이 화학 단위를 알려 주는지 각각 따로 묻습니다. 빠진 정보를 임의로 채워 넣지 않습니다.
Python 또는 R 한 언어를 먼저 선택하세요. 브라우저는 실제로 실행해 보관한 고정 기록과 공개 메타데이터를 보여 주며 새 Python/R 프로세스를 실행하지 않습니다. 내려받은 코드는 같은 파일 구조를 유지해 실제 언어 환경에서 실행할 수 있습니다.
A file opens, but every value appears in one column. Korean labels become unreadable, or a date moves to another month. Even an error-free import need not represent the intended observations. Follow bytes→characters→records and fields→types→units and time meaning.
Start with a small toy CSV, then read 180 actual BIS quarterly values, 3,150 UCI customer rows and 1,599 red-wine rows. Ask separately whether a charge-level code is money, a quarter boundary is a measurement timestamp, or a chemical header establishes its unit. Do not invent unavailable metadata.
Choose Python or R first. The browser displays fixed archived actual runs and public metadata; it does not start a language process. Downloaded code can run in a real runtime with the retained folder structure.
기초Foundations
2. 확장자보다 실제 저장 형식을 확인한다2. Inspect serialization rather than trusting a suffix
파일 확장자는 이름의 일부입니다. 이 보관 자료의 원 BIS 파일은 이름 끝이 .csv이지만 첫 바이트를 문자로 읽으면 XML 선언으로 시작하며 실제 구조는 SDMX XML입니다. 같은 이름이 모든 시스템에서 실제 형식을 보장한다고 가정하면 잘못된 읽기 함수를 고를 수 있습니다.
이 장은 보관 원파일의 바이트를 그대로 복사한 actual-BIS-real.xml을 새 실행 예제의 입력으로 씁니다. 확장자를 바꿔 내용을 변환한 것이 아니라, 실제 구조를 설명하는 작업 사본을 만든 것입니다. Python 예제는 XML 파서를 쓰며 R 예제는 이 보관 파일의 Obs 태그만 확인하는 제한된 검사라고 명시합니다.
A suffix is part of a name. The archived BIS source ends in .csv but begins with an XML declaration and contains SDMX XML. A suffix is not a universal guarantee of serialization; trusting it can select the wrong reader.
The new execution example uses a byte-identical working copy named actual-BIS-real.xml. Renaming did not convert its contents. Python uses an XML parser; the R example explicitly limits its inspection to Obs tags in this retained serialization.
기초Foundations
3. 물리적인 줄과 관측 행을 구분한다3. Separate physical lines from logical records
행은 관측 기록이고 열은 변수라는 표를 만들고 싶다고 합시다. 저장 텍스트의 줄바꿈 하나가 언제나 관측 하나인 것은 아닙니다. 따옴표 안의 설명 문자열이 여러 줄에 걸칠 수 있기 때문입니다. 머리글도 관측 행 수에서 따로 셉니다.
가정 파일은 이름과 메모 두 필드, Alice·Bob·Zero 세 기록입니다. Bob의 메모에는 줄바꿈이 있고 Alice의 메모에는 쉼표가 있습니다. 선언한 CSV 읽기로 두 언어 모두 데이터 3행·2열을 얻었습니다. 텍스트를 줄마다 자르고 쉼표마다 나누는 것만으로 같은 결과를 보장하지 않습니다.
name,note
Alice,"Seoul, Korea"
Bob,"line one
line two"
Zero,""
A table may assign observations to records and variables to fields. A stored newline does not always delimit an observation: quoted text can span lines. Count the header separately from data records.
The toy file contains two fields and three records: Alice, Bob and Zero. Alice’s note includes a comma; Bob’s includes a newline. Both declared readers returned three data records and two fields. Simply splitting on every newline and comma does not guarantee that result.
name,note
Alice,"Seoul, Korea"
Bob,"line one
line two"
Zero,""
기초Foundations
4. 구분자와 소수점 표지는 다른 약속이다4. A delimiter and a decimal mark are different conventions
쉼표·세미콜론·탭은 필드를 나누는 구분자로 쓰일 수 있습니다. 소수점 점이나 쉼표는 한 수 안의 표기입니다. 실제 레드 와인 파일은 세미콜론으로 열을 나누고 소수점은 점으로 씁니다. 세미콜론 파일이라는 이유로 소수점도 쉼표라고 추측하지 않습니다.
R의 read.csv2는 기본 구분자와 소수점 약속이 read.csv와 다릅니다. 이 장의 코드는 파일의 실제 약속을 명시합니다. 읽기 함수 이름을 외우는 대신 sep·dec·quote·머리글·결측 표식을 입력 계약에 적습니다.
Commas, semicolons and tabs can separate fields. A dot or comma can instead mark a decimal inside one number. The actual red-wine file separates fields with semicolons and uses decimal dots. Do not infer decimal commas merely from semicolon separation.
R’s read.csv2 has different delimiter/decimal defaults from read.csv. This chapter states the file’s actual conventions explicitly. Record sep, dec, quote, header and missing-marker rules rather than memorizing a function name.
기초Foundations
5. 따옴표 안의 쉼표와 줄바꿈을 보존한다5. Preserve commas and newlines within quoted fields
"Seoul, Korea"는 이 CSV 약속에서 하나의 문자열 필드입니다. 따옴표는 데이터를 해석하는 문법이고 값의 일부로 따옴표가 필요한 경우에는 별도 이스케이프 규칙도 있습니다. 문자에 쉼표가 보인다고 필드가 둘이라고 세지 않습니다.
Python 예제는 파일을 newline=""으로 열고 csv.reader가 CSV 줄 끝과 인용을 해석하게 합니다. R 예제도 인용 문자와 빈 줄·채우기 정책을 명시합니다. 선언을 바꾸면 일부 파일은 오류를 내고, 다른 파일은 성공 상태로 전혀 다른 표를 만들 수 있습니다.
"Seoul, Korea" is one field under this CSV convention. Quoting is syntax, with separate escaping rules when a quote belongs in a value. A visible comma need not separate fields.
The Python program opens with newline="" so csv.reader handles CSV newlines and quoting. The R program states quoting and blank/fill policies too. Changing conventions can cause an error or can silently produce a different table.
기초Foundations
6. 실제 와인 파일을 읽은 코드를 따라간다6. Trace code that read the actual wine file
다음은 보관 레드 와인 CSV를 실제 Python으로 읽은 코드와 출력입니다. 원자료 문자열을 우선 보존하고 데이터 행 수·열 수·첫 기록·각 행 폭을 확인합니다. 입력 파일 경로는 명령 인자로 전달합니다. 읽기 성공을 자동 숫자 변환이나 측정 의미의 검증과 혼동하지 않습니다.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
import csv,json,sys
from pathlib import Path
path=Path(sys.argv[1])
with path.open(encoding="utf-8-sig",newline="") as handle:
records=list(csv.reader(handle,delimiter=';'))
print(json.dumps({"dataRows":len(records)-1,"columns":len(records[0]),"headers":records[0],"firstRecord":records[1],"sameWidth":all(len(x)==len(records[0]) for x in records)},ensure_ascii=False))
선언한 세미콜론 읽기는 1,599행·12열입니다. 쉼표를 구분자로 지정한 기록은 같은 1,599개 줄을 1열로 읽습니다. 원측정의 수가 달라진 것이 아니라 파싱 계약이 잘못된 것입니다. 두 기록 모두 프로세스 종료 상태만 보면 성공일 수 있습니다.
This source and output come from actually reading the retained red-wine CSV in Python. Preserve source strings first, then inspect row count, field count, first record and row widths. The input path is a command argument. Reading success does not itself establish numerical conversion or measurement meaning.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
import csv,json,sys
from pathlib import Path
path=Path(sys.argv[1])
with path.open(encoding="utf-8-sig",newline="") as handle:
records=list(csv.reader(handle,delimiter=';'))
print(json.dumps({"dataRows":len(records)-1,"columns":len(records[0]),"headers":records[0],"firstRecord":records[1],"sameWidth":all(len(x)==len(records[0]) for x in records)},ensure_ascii=False))
The declared semicolon read gives 1,599 rows and twelve fields. A comma read yields one field for the same file. It changes parsing, not the number of original measurements. Both processes can exit successfully.
기초Foundations
7. 성공 종료 뒤에도 읽기 계약을 검사한다7. Check the import contract after a successful exit
모든 행 폭이 같다는 검사는 유용하지만 충분하지 않습니다. 실제 와인 파일을 1열로 잘못 읽어도 모든 행이 1열이라 폭 검사를 통과할 수 있습니다. 기대 열 이름·열 수·원행 수·첫 원값·결측 규칙을 각각 확인해야 합니다.
가정 인용 CSV를 잘못된 구분자로 읽은 실제 기록에서는 Python과 R의 행 해석도 달랐습니다. 이를 어느 언어가 언제나 맞다는 경쟁으로 읽지 않습니다. 선언한 reader 옵션과 이번 입력에서 실제 어떤 표가 만들어졌는지 조사합니다. 새 데이터의 모든 오류를 몇 개 예제로 증명했다고 말하지 않습니다.
Equal row width is useful but insufficient. A wrong one-field wine import can pass that check because every row has one field. Separately check expected names/counts, source-row count, initial source values and missingness conventions.
The actual wrong-delimiter runs on quoted toy text also differed between Python and R. This does not establish a universally superior language. Inspect each reader’s options and the table actually produced for this input. Finite examples do not prove every possible import correct.
기초Foundations
8. 실습 A: 읽기 약속과 실제 표를 비교한다8. Lab A: compare declared parsing with actual tables
언어·자료·구분자 선택을 바꾸고 먼저 예상하세요. 실제 와인의 12열, 고객의 14열, 따옴표를 가진 가정 기록의 2열, XML인 BIS의 구조를 구분합니다. 오류·종료 상태·읽힌 행과 열을 따로 봅니다.
이 실습은 실제로 준비한 16개 읽기 기록을 선택합니다. 사용자의 임의 파일을 브라우저에서 Python/R로 처리하지 않습니다. 다운로드 코드에서 새 입력을 사용했다면 입력과 코드의 새 식별값·실행 결과를 따로 남기세요.
Change language, source and parsing choice, then predict. Distinguish twelve wine fields, fourteen customer fields, two quoted-toy fields and BIS XML. Read errors, exit status and parsed shape separately.
The lab selects sixteen archived actual parsing runs. It does not process arbitrary user files in a browser Python/R interpreter. Retain new input/code identifiers and output when running changed inputs separately.
기초Foundations
9. 자료사전은 열의 의미를 설명한다9. A data dictionary explains a field’s meaning
같은 숫자 3이 나이, 연령 집단 코드, 통화 수, 점수 중 무엇인지 열 이름만으로 항상 알 수 없습니다. 자료사전은 원 변수명·뜻·자료형·단위·범주 코드·결측·관측 기간·출처를 연결하는 설명입니다. 수치로 저장되었다는 사실과 수량 척도라는 사실은 다릅니다.
원 자료사전이 알려 주지 않는 정보는 ‘모름’으로 남깁니다. 잘 알려진 다른 자료셋의 단위나 비슷한 논문의 정의를 가져와 이번 열의 사실처럼 쓰지 않습니다. 사전도 원자료와 함께 버전과 출처를 보관합니다.
The same stored three can be age, an age-group code, a call count or an ordered score. A dictionary connects source name, meaning, type, units, category codes, missingness, time and provenance. Numerical storage does not establish a quantitative measurement scale.
Keep unavailable metadata unknown. Do not import units from another familiar dataset or a similar paper and present them as this field’s source definition. Preserve dictionary versions and provenance alongside data.
기초Foundations
10. 원 머리글과 분석용 이름을 함께 보존한다10. Retain source headers alongside analysis names
실제 고객 원 CSV에는 Call Failure처럼 공백 두 개가 있는 이름이 있습니다. 화면에서 공백을 눈으로 세기 어렵기 때문에 코드가 기대한 이름과 다를 수 있습니다. call_failure 같은 분석 이름을 쓰더라도 원 이름과의 대응표를 남깁니다.
이름 정리는 관측값 변경과 별도 작업입니다. 어떤 도구는 이름을 자동으로 바꾸므로 R 예제는 check.names=FALSE로 원 이름을 우선 보존합니다. 깨끗해 보이는 이름이 원문이라는 가정을 하지 않습니다.
The actual customer CSV includes a double space in Call Failure. Such differences can be hard to see yet matter in exact field lookup. If analysis uses call_failure, retain its mapping to the source name.
Renaming differs from changing observations. Tools may automatically alter names; the R examples use check.names=FALSE to retain originals initially. A tidy-looking name is not necessarily the source header.
기초Foundations
11. 이름 대응은 충돌 없이 확인한다11. Verify that a rename map has no collisions
단순히 공백을 모두 지우면 A B와 AB가 같은 이름이 됩니다. 한 이름으로 합쳐진 뒤에는 어느 원 열이었는지 잃을 수 있습니다. 원 이름·분석 이름의 중복을 각각 검사하고 명시한 대응표가 필요한 열을 모두 포함하는지 확인합니다.
분석 이름을 만드는 규칙이 유일한 정답일 필요는 없습니다. 핵심은 충돌을 숨기지 않고 원행·원값과 연결할 수 있게 하는 것입니다. 출처 키나 범주 코드를 이름 정리와 함께 임의로 다시 번호 매기지 않습니다.
Deleting spaces maps both A B and AB to one name. Such collisions can lose source-field identity. Check duplicates on both sides of a rename map and whether every required field is included.
There need not be one universal naming style. Expose collisions and preserve links to source fields and values. Do not silently renumber source keys or category codes as part of header cleanup.
기초Foundations
12. 요금 수준 코드는 화폐 금액이 아니다12. A charge-level code is not a currency amount
고객 자료의 Charge Amount는 0~9의 요금 수준 코드입니다. 0을 결측이라고 지우거나 9를 9달러라고 바꾸지 않습니다. Age Group의 1~5도 연령 집단 코드이며 1~5세라는 뜻이 아닙니다.
순서가 있으면 큰 코드와 작은 코드의 범주 순서를 읽을 수 있지만, 코드 차이 1이 항상 같은 금액·나이 차이라는 뜻은 아닙니다. 평균 코드가 어떤 질문에 유용한지는 별도 모형 선택입니다. 원자료의 의미를 자동으로 만들어 주지는 않습니다.
Charge Amount is a charge-level code from zero to nine. Do not drop zero as missing or convert nine into nine dollars. Age Group values one to five are group codes, not ages one through five.
An ordering does not imply equal monetary or age distances between adjacent codes. A mean code requires a separate modeling purpose; arithmetic does not create source measurement meaning.
기초Foundations
13. 이진 코드의 0과 미관측을 나눈다13. Separate binary zero from missingness
고객의 불만·이탈 표시는 선언한 0/1 코드입니다. 0은 불만 없음·이탈 아님이라는 관측 범주일 수 있습니다. 빈 칸·NA 같은 미관측 표식과 같은 것으로 처리하면 분모와 범주 비중이 바뀝니다.
실제 고객 원파일은 공개 설명에서 결측이 없다고 제시된 기록이며, 이 장도 실제 전체 셀을 보존합니다. 이 설명을 모든 향후 고객 파일의 무결측 보증으로 일반화하지 않습니다. 새 파일에서는 원코드 범위·변환 실패·미관측을 다시 검사합니다.
Complaint and churn use declared binary codes. Zero can mean observed no complaint or no churn; it is not equivalent to blank or NA. Treating it as missing changes denominators and category shares.
The public description states no missing values for this customer file, and this chapter retains all actual cells. This is not a guarantee for future customer files. Recheck code domains, conversion failures and missingness on each new input.
기초Foundations
14. 와인 점수는 순서와 관측 범위를 가진다14. Wine scores have an ordering and an observed range
레드 와인 자료의 quality는 적어도 세 전문가 평가의 중앙값으로 설명된 순서형 점수입니다. 자료사전의 가능한 점수 범위와 이번 레드 부분집합에서 실제 관측된 값의 범위도 구별합니다. 실제 같은 숫자의 반복만으로 같은 와인병을 중복 입력했다고 단정하지 않습니다.
점수의 평균이나 제곱손실 회귀를 사용할 수는 있지만, 순서 점수 간 간격을 수량처럼 다루는 분석 선택을 밝힙니다. 전문 평가 점수로 시장 가격·브랜드·생산 기업이나 모든 소비자의 만족도를 알아냈다고 말하지 않습니다.
Wine quality is described as an ordered score based on the median of at least three expert evaluations. Distinguish its stated possible scale from values observed in this red subset. Equal recorded values alone do not establish duplicated bottles.
A mean score or squared-loss regression is an analytical choice treating score gaps numerically. State that choice. Expert scores do not identify market prices, brands, production firms or every consumer’s satisfaction.
기초Foundations
15. 열 이름이 단위를 주지 않을 때 멈춘다15. Pause when a header does not establish units
와인 CSV의 residual sugar 같은 이름은 측정 대상의 단서이지만, 이 보관 머리글과 names 파일만으로 모든 화학 열의 단위를 확정하지 않습니다. 다른 교재에서 본 단위를 가져와 원자료의 확인된 단위처럼 환산하지 않습니다.
이 장의 단위 실습은 실제 첫 기록 값 1.9를 읽되, 확인되지 않은 화학 단위 변환을 수행하지 않습니다. 원 측정 방법을 확인한 뒤 단위 변환식을 정할 수 있습니다. 정보를 모른다는 명시적 상태는 읽기 실패나 숫자 0과 다릅니다.
A header such as residual sugar suggests a measured property but does not establish every chemical unit from the retained header and names file alone. Do not borrow a familiar unit and label it source-verified.
The unit lab reads the actual first value 1.9 but performs no unsupported chemical conversion. Verify the primary method before choosing a conversion. Explicitly unknown metadata differs from an import error or numerical zero.
기초Foundations
16. 실습 B: 원 변수명·코드·단위를 읽는다16. Lab B: inspect source names, codes and units
고객·와인·BIS 자료와 열을 선택해 원 이름, 분석 이름, 설명, 코드·단위, 시간 해석을 비교합니다. 원 변수명의 공백·대소문자는 보존하고, 사전에 없는 사실을 새로 계산해 넣지 않습니다.
이 실습은 공개 사전의 명시적 대응을 조회하는 JavaScript 표시입니다. Python/R 실행이나 자동 메타데이터 추론이라고 소개하지 않습니다. 잘못된 열 선택은 이전 결과를 지우고 선택을 고칠 수 있게 합니다.
Select a source and field to compare original name, analysis name, definition, codes/units and timing. Retain source spacing and case; do not invent facts absent from the dictionary.
This is an explicit JavaScript metadata lookup, not Python/R execution or automatic metadata inference. An invalid selection clears prior results so it can be corrected.
기초Foundations
17. 날짜·기간·시각은 같은 대상이 아니다17. A date, a period and an instant are different objects
2024-04-03은 달력 날짜이고 2024-Q2는 4~6월이라는 기간 표지입니다. 특정 시각을 뜻하려면 시·분·초와 필요한 시간대 정보도 있어야 합니다. 기간 자료를 그래프에 찍기 위해 한 날짜를 택했다고 그날 한 번 측정했다는 뜻이 되지 않습니다.
BIS 분기 지수는 기간에 대응하는 집계·지수 자료입니다. 이 장은 분기의 첫날과 마지막 날을 계산해 표시하지만 원 측정의 정확 시각을 새로 발견한 것은 아닙니다. 관측 기간, 발표 날짜, 내려받은 날짜도 서로 다른 필드로 기록합니다.
2024-04-03 is a calendar date; 2024-Q2 labels the April–June period. An instant needs time-of-day and, when relevant, time-zone information. Choosing a plot date for a period does not establish that measurement occurred on that one day.
BIS quarterly indices describe periods. This chapter derives quarter boundaries for display without discovering precise measurement instants. Observation period, release date and retrieval date belong in separate fields.
기초Foundations
18. 03/04/2024는 어느 날짜인가18. Which date does 03/04/2024 mean?
가정 문자열 03/04/2024를 일/월/년으로 읽으면 2024년 4월 3일, 월/일/년으로 읽으면 3월 4일입니다. 둘 다 달력상 가능한 날짜라서 파싱 성공만으로 원뜻을 고를 수 없습니다. 출처의 형식 약속이 필요합니다.
이번 실제 두 언어 실행에서도 %d/%m/%Y와 %m/%d/%Y가 각각 다른 유효 날짜를 냈습니다. 프로그램의 기본 지역 설정이 원자료의 약속을 대신하지 않습니다. 원 문자열과 선언 형식을 함께 보존한 뒤 ISO 형태로 표시합니다.
Under day/month/year, toy text 03/04/2024 means April 3; under month/day/year it means March 4. Both are valid calendar dates, so parsing success cannot select the source meaning. A source format convention is required.
Actual runs in both languages produced the two dates under %d/%m/%Y and %m/%d/%Y. A machine locale is not the source dictionary. Retain original text and declared format before displaying ISO dates.
기초Foundations
19. 없는 날짜와 미관측 날짜를 나눈다19. Separate an impossible date from a missing date
2024년은 윤년이어서 2월 29일이 있지만 2023년에는 없습니다. 실제 고정 예제의 Python은 잘못된 2023-02-29에서 ValueError로 멈췄고 R의 명시 형식 as.Date는 NA를 반환했습니다. 같은 오류 표현을 두 언어에 억지로 붙이지 않습니다.
R 프로세스 종료 상태 0은 날짜가 유효하다는 뜻이 아닙니다. 변환 뒤 미관측 상태와 원래부터 날짜가 없었던 표식도 구별해야 합니다. 원 문자열·변환 결과·실패 이유를 함께 남기고 잘못된 날짜를 자동으로 다른 날로 고치지 않습니다.
February 29 exists in leap year 2024 but not in 2023. In the fixed actual runs, Python stopped with ValueError for 2023-02-29; R’s explicitly formatted as.Date returned NA. Do not invent a shared error behavior for different languages.
R exit status zero does not establish a valid parsed date. A missing value created by conversion also differs from an originally unavailable date. Retain source text, result and failure reason rather than silently changing an impossible date.
기초Foundations
20. 분기에서 달력 경계를 유도한다20. Derive calendar boundaries from a quarter label
분기 번호 q가 1~4이면 시작 월은 3q−2, 마지막 월은 3q입니다. 1분기는 1월 1일부터 3월 31일까지, 2분기는 4월 1일부터 6월 30일까지입니다. 마지막 날짜는 모든 달이 30일이라고 가정하지 않고 실제 달력으로 구합니다.
실제 보관 180분기에서 두 언어가 계산한 경계는 1980-Q1의 1980-01-01~1980-03-31부터 2024-Q4의 2024-10-01~2024-12-31까지입니다. 원래 날짜가 아닌 파생 달력 경계라는 플래그도 유지합니다. 이후 결합에서 이 날짜를 원자료의 정확 측정일이라고 쓰지 않습니다.
For quarter number q from one to four, the first month is 3q−2 and last month 3q. Quarter one runs January 1–March 31; quarter two April 1–June 30. Use a real calendar instead of assuming every month has thirty days.
For the 180 retained periods, both languages derived boundaries from 1980-Q1’s January 1–March 31 through 2024-Q4’s October 1–December 31. A flag retains their derived status. Do not later join them as if they were precise source measurement dates.
기초Foundations
21. 실제 180개 분기의 날짜 코드를 읽는다21. Read the actual 180-quarter date program
Python 예제는 보관 표의 연도와 분기 번호에서 날짜를 계산하고, 이미 보관한 파생 날짜와 전부 비교합니다. 실제 원 지수 값은 바꾸지 않습니다. 이 검사는 같은 파생 규칙을 재현하는지 확인하며 원자료의 시간 집계 정의를 새로 검증한 것은 아닙니다.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
import calendar,csv,json,sys
from datetime import date
with open(sys.argv[1],encoding="utf-8-sig",newline="") as handle:rows=list(csv.DictReader(handle))
derived=[]
for row in rows:
year=int(row["year"]);quarter=int(row["quarter_number"])
start=date(year,3*quarter-2,1);month=3*quarter
end=date(year,month,calendar.monthrange(year,month)[1])
assert start.isoformat()==row["calendar_quarter_start"]
assert end.isoformat()==row["calendar_quarter_end"]
derived.append({"period":row["source_period"],"start":start.isoformat(),"end":end.isoformat()})
print(json.dumps({"records":len(rows),"first":derived[0],"last":derived[-1],"calendarBoundsAreSourceTimestamps":False}))
R 예제는 다음 분기의 첫날에서 하루를 빼 마지막 날을 구합니다. 4분기 다음은 다음 해 1월이므로 연도와 월을 함께 넘깁니다. 날짜 차이의 단위가 일인지, 초인지도 자료형과 함께 확인합니다.
The Python example derives dates from retained year/quarter fields and compares every result with the archived derived dates. It leaves source index values unchanged. This checks reproduction of the declared calendar rule, not a newly established source aggregation definition.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
import calendar,csv,json,sys
from datetime import date
with open(sys.argv[1],encoding="utf-8-sig",newline="") as handle:rows=list(csv.DictReader(handle))
derived=[]
for row in rows:
year=int(row["year"]);quarter=int(row["quarter_number"])
start=date(year,3*quarter-2,1);month=3*quarter
end=date(year,month,calendar.monthrange(year,month)[1])
assert start.isoformat()==row["calendar_quarter_start"]
assert end.isoformat()==row["calendar_quarter_end"]
derived.append({"period":row["source_period"],"start":start.isoformat(),"end":end.isoformat()})
print(json.dumps({"records":len(rows),"first":derived[0],"last":derived[-1],"calendarBoundsAreSourceTimestamps":False}))
The R counterpart subtracts one day from the next quarter’s start. After quarter four, it moves both year and month to next January. Check whether date differences are measured in days or seconds under the selected type.
기초Foundations
22. 상대 월 번호로 달력 연도를 만들지 않는다22. Do not invent calendar years from relative month numbers
고객 자료 설명의 첫 9개월 속성과 12개월째 이탈은 상대적인 시간 창입니다. 시작 달력 연도가 제공되지 않았다면 ‘2024년 9월’처럼 바꿀 수 없습니다. 가입 기간 38개월도 기간 길이이며 그 자체로 가입 날짜가 되지 않습니다.
와인 측정 기록의 원행 번호도 측정 날짜가 아닙니다. 행을 그 순서로 그린 그림은 원행 순서의 그림일 뿐, 시간 추세라고 부르려면 실제 시점과 정렬 기준이 더 필요합니다. 만들어낸 시간 정보를 원자료에 다시 써 넣지 않습니다.
The customer description’s first-nine-month attributes and month-twelve churn define relative windows. Without a calendar origin, they cannot become “September 2024.” A subscription length of 38 months is a duration, not a subscription date by itself.
A wine source-row number is not its measurement date either. A plot by row order is not automatically a time trend. Actual times and ordering rules are required; do not write invented calendar information back into the source.
기초Foundations
23. 시각에 시간대가 빠지면 무엇을 모르는가23. What is unknown when an instant lacks a time zone?
오전 9시라는 기록만으로 전 세계의 한 순간을 정할 수는 없습니다. 날짜·장소·시간대 규칙이 필요할 수 있습니다. 같은 현지 시각이 계절 시간 변경에서 모호하거나 존재하지 않을 수도 있으므로 실제 시스템의 규칙을 확인합니다.
이 장의 고정 날짜 실습은 달력 날짜와 분기 경계만 다루며 시간대 변환을 실행하지 않습니다. 단순 날짜 예제의 성공을 모든 시각·시간대 처리의 인증이라고 넓히지 않습니다. 시간대 규칙은 바뀔 수 있어 실제 분석 시점의 자료와 라이브러리 버전을 기록합니다.
A record saying 9 a.m. does not identify one global instant. Date, location and time-zone rules may be needed. Clock transitions can make local times ambiguous or nonexistent; consult the actual system’s rules.
The fixed labs here cover calendar dates and quarter boundaries, not executed time-zone conversion. Their success is not certification of every timestamp problem. Record the time-zone data and runtime version when those rules matter.
기초Foundations
24. 실습 C: 형식·윤일·분기 경계를 구별한다24. Lab C: distinguish formats, leap days and quarter boundaries
두 유효 해석을 가진 문자열, 유효·무효 윤일, 실제 180분기 경계 계산을 선택합니다. 종료 상태와 변환값이 모두 의미 있는지 확인하세요. R의 NA 반환은 날짜 변환 실패를 뜻할 수 있어 원래 결측과 따로 기록합니다.
여기서 선택하는 10개 기록은 실제 Python/R 프로세스에서 준비했습니다. 브라우저의 날짜 자동 파서로 임의 입력을 해석한 뒤 Python/R 결과처럼 보여 주지 않습니다.
Select a string with two valid interpretations, valid/invalid leap days, or the actual 180-quarter calculation. Inspect both exit status and parsed value. R’s returned NA can arise from conversion rather than source missingness.
These ten records were prepared in actual Python/R processes. The browser does not substitute its own general date parser and present that as language execution.
기초Foundations
25. 단위는 숫자 옆의 장식이 아니다25. Units are part of a quantity’s meaning
사용 시간이 120이라는 기록은 120초인지 120분인지에 따라 60배 다릅니다. 관측 단위가 고객 한 명이라는 말과 변수의 측정 단위가 초라는 말도 다릅니다. 자료사전에 둘을 각각 적습니다.
열 이름이 seconds라면 먼저 출처에서 시간 범위·집계 방식까지 확인합니다. 같은 초 단위라도 하루 합과 9개월 합은 다른 질문입니다. 단위를 맞춘 뒤에도 관측 대상과 기간을 맞추어야 비교할 수 있습니다.
A usage value of 120 differs by a factor of sixty between seconds and minutes. “One customer record” is an observation unit; seconds are a measurement unit. Record both.
Even a seconds label needs source timing and aggregation context. Daily totals and nine-month totals can use the same unit while answering different questions. Unit conversion does not replace matching populations and periods.
기초Foundations
26. 환산 계수를 곱하고 결측을 보존한다26. Apply a conversion factor while preserving missingness
초를 분으로 바꾸려면 60으로 나눕니다. 가정 자료 0,60,120,미관측은 0,1,2,미관측 분이 됩니다. 관측 0은 남고 미관측이 0으로 생기지 않습니다. 가용값 세 개의 평균은 60초=1분입니다.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
import json
seconds=[0,60,120,None]
minutes=[None if x is None else x/60 for x in seconds]
valid=[x for x in seconds if x is not None]
print(json.dumps({"seconds":seconds,"minutes":minutes,"nAvailable":len(valid),"meanSeconds":sum(valid)/len(valid),"meanMinutes":sum(valid)/len(valid)/60}))
환산은 원값을 버리라는 뜻이 아닙니다. 원 단위 열과 환산 열의 이름을 나누고 배수를 기록합니다. 가용 분모가 그대로인지 확인하면 환산 중 결측 처리 오류도 찾기 쉽습니다.
Divide seconds by sixty to obtain minutes. Toy values 0,60,120, missing become 0,1,2, missing. Observed zero remains; missingness does not become zero. The three available values average sixty seconds or one minute.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
import json
seconds=[0,60,120,None]
minutes=[None if x is None else x/60 for x in seconds]
valid=[x for x in seconds if x is not None]
print(json.dumps({"seconds":seconds,"minutes":minutes,"nAvailable":len(valid),"meanSeconds":sum(valid)/len(valid),"meanMinutes":sum(valid)/len(valid)/60}))
Conversion need not discard the source values. Name source and converted columns separately and record the factor. Checking the unchanged available denominator helps detect conversion-related missingness mistakes.
기초Foundations
27. 단위를 바꾸면 분산은 배수의 제곱으로 바뀐다27. Variance changes by the square of a scale factor
모든 가용 측정값에 같은 상수 a를 곱하면 평균에는 a, 분산에는 a²가 곱해집니다. 같은 가용 행과 같은 분모를 비교한다는 조건입니다. 초에서 분으로 바꾸면 a=1/60이므로 분산은 1/3600배이고 단위는 분²입니다.
0,60,120의 기술 평균은 60초이고 분모 n=3의 기술분산은 (3600+0+3600)/3=2400초²입니다. 0,1,2의 분산은 2/3분²로 2400/3600과 같습니다. 표준편차는 양의 단위 환산에서 1/60배입니다. 산술값이 작아졌다고 자료의 상대적 변동이 없어졌다고 말하지 않습니다.
Multiplying the same available observations by constant a multiplies their mean by a and variance by a² under a common denominator. Seconds-to-minutes uses a=1/60, so variance scales by 1/3600 and its unit becomes minutes squared.
Values 0,60,120 average sixty seconds and have n-denominator variance 2400 seconds². Values 0,1,2 have variance 2/3 minutes²=2400/3600. Standard deviation scales by 1/60 for this positive conversion. Smaller numerical variation does not mean the relative pattern disappeared.
기초Foundations
28. 척도 변환과 단순 곱셈을 구별한다28. Distinguish affine scales from pure multiplication
센티미터와 미터의 환산은 일정한 양의 배수지만 섭씨와 화씨는 원점을 옮기는 항도 있습니다. 앞 장의 자료형 예처럼 계산할 수 있어도 수준 비율의 해석이 보존되는 것은 아닙니다. 어떤 측정 척도인지 알아야 올바른 비교를 고릅니다.
이번 여섯 실습은 온도 변환을 새로 실행하지 않습니다. 이 절은 환산식을 정할 때 확인할 개념을 연결합니다. 같은 단위 차원이 있다고 평균·한계·총량이 같은 값이 되지 않으며, 달러 표시만 같아도 서로 다른 연도의 구매력이 같아지는 것은 아닙니다.
Centimeters-to-meters is a positive scale change; Celsius-to-Fahrenheit also shifts the origin. Computable arithmetic does not preserve every interpretation of level ratios. Choose comparisons using the measurement scale.
The six labs do not newly execute temperature conversion. This section connects concepts needed before selecting a formula. Matching dimensions do not make averages, marginal rates and totals equal; matching dollar labels do not equalize purchasing power across years.
기초Foundations
29. 지수 재기준은 화폐 환산이 아니다29. Index rebasing is not a currency conversion
가정 지수 80,100,120에서 첫 값을 새 기준 100으로 놓으면 각 값에 100/80을 곱해 100,125,150을 얻습니다. 각 시점의 비율과 증감률은 보존하지만 수준 숫자의 기준은 바뀝니다. 이것을 달러 환산이나 물가 조정이라고 부르지 않습니다.
실제 BIS 지수의 메타데이터는 2010년 평균=100이라는 기준을 줍니다. 보관한 소수 공표값 네 개의 평균은 100과 아주 조금 다를 수 있습니다. 반올림된 관측 평균과 지수 작성 기준을 구별하고 원값을 고쳐 100에 억지로 맞추지 않습니다.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
from fractions import Fraction
import json
values=[Fraction(80),Fraction(100),Fraction(120)]
rebased=[x/values[0]*100 for x in values]
print(json.dumps({"sourceIndex":[str(x) for x in values],"chosenReference":"80","rebasedIndex":[str(x) for x in rebased],"currencyConversionPerformed":False}))
For toy indices 80,100,120, choosing the first value as a new reference of one hundred multiplies all by 100/80, yielding 100, 125, 150. Ratios and growth rates remain unchanged while reference levels change. This is not conversion into dollars or inflation adjustment.
BIS metadata specify average 2010=100. The mean of four retained rounded published values can differ slightly from 100. Separate a source construction reference from a mean computed on displayed decimals; do not edit observations to force agreement.
import sys
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
from fractions import Fraction
import json
values=[Fraction(80),Fraction(100),Fraction(120)]
rebased=[x/values[0]*100 for x in values]
print(json.dumps({"sourceIndex":[str(x) for x in values],"chosenReference":"80","rebasedIndex":[str(x) for x in rebased],"currencyConversionPerformed":False}))
30. 명목·실질·기준 연도를 별도 메타데이터로 둔다30. Keep nominal, real and reference-year metadata separate
명목 주택 지수와 물가로 조정한 실질 지수는 다른 변수를 나타냅니다. 둘 다 기준 100의 지수라고 같은 열로 합치지 않습니다. 실질 지수의 물가 조정 방식과 기준 연도, 주택 범위는 원자료 설명을 따라야 합니다.
한국 BIS 보관 시계열의 앞 24분기는 주거·비주거 토지 가격 대용 범위를 사용하고 뒤는 주택 범위로 이어집니다. 숫자가 끊김 없이 있다는 이유로 측정 대상이 전 기간 완전히 같다고 단정하지 않습니다. 범위 전환 표지를 남기고 장기 비교의 한계를 설명합니다.
A nominal housing index and a consumer-price-adjusted real index are different variables. Their common reference of one hundred does not make them interchangeable. Preserve the source’s adjustment method, reference year and housing coverage.
The first 24 quarters of the retained Korean series use a residential/nonresidential land-price proxy before later dwelling coverage. A numerically continuous series does not establish identical measurement scope throughout. Retain the coverage transition and explain limits of long-run comparison.
기초Foundations
31. 환산 전후에 무엇이 보존되는지 적는다31. State invariants before and after conversion
순수 양의 배수 환산에서는 원행 수·가용성·순서·같음 관계가 보존되어야 합니다. 숫자 합과 평균은 배수만큼, 분산은 제곱만큼 바뀝니다. 범주 코드를 단위량으로 잘못 취급하는 일은 이런 환산이 아닙니다.
화학 단위가 확인되지 않은 실제 열은 이번 코드에서 변환하지 않습니다. ‘변환 안 함’은 값이 0이거나 읽기에 실패했다는 뜻이 아니라, 환산 계수를 정할 출처 근거가 없다는 명시적인 결정입니다. 나중에 확인한 단위는 새 사전 버전으로 추가합니다.
A positive multiplicative conversion should preserve source count, availability, order and equality. Sums/means scale once and variances twice in the exponent. Treating a category code as a measurement is not such a conversion.
The code performs no chemical-unit conversion when source units are unverified. “Not converted” does not mean zero or failed import; it records insufficient evidence for a conversion factor. Add subsequently verified units in a new dictionary version.
기초Foundations
32. 실습 D: 실제 환산·재기준·환산 보류를 비교한다32. Lab D: compare conversion, rebasing and withheld conversion
초→분의 가정 자료, 첫 값을 100으로 만드는 가정 지수, 실제 와인 열의 미확인 단위를 선택합니다. 분모·원값·환산값·단위 확인 상태를 분리해 읽습니다. 모든 수가 저장되어 있어도 모든 변환이 정당화되지는 않습니다.
이 실습의 여섯 실제 실행은 고정 입력만 처리합니다. 사용자가 선택한 임의 환산식을 Python/R이 검증했다는 뜻은 아닙니다. 새로운 단위 변환은 근거와 함께 실제 코드로 별도 검사하세요.
Select toy seconds-to-minutes, a toy index rebased to one hundred, or an actual wine field with unverified units. Separate denominator, source values, converted values and metadata status. Stored numbers do not justify every transformation.
The six actual runs use fixed inputs. They do not establish that Python/R validated an arbitrary user formula. Test a new conversion separately with its source justification.
기초Foundations
33. 보이는 글자와 저장 바이트를 나눈다33. Separate displayed characters from stored bytes
화면에 보이는 한글과 파일 속 바이트는 다른 층입니다. 인코딩은 문자를 바이트로 나타내는 약속이며 디코딩은 그 약속으로 바이트를 읽는 과정입니다. 숫자처럼 보이는 바이트만으로 그 파일이 어느 인코딩인지 항상 유일하게 알아낼 수 있는 것은 아닙니다.
같은 문장을 다른 인코딩으로 저장하면 바이트 수와 해시는 달라질 수 있습니다. 반대로 일부 ASCII 글자는 여러 인코딩에서 같은 바이트를 쓰므로 앞부분이 잘 보인다고 전체 해석까지 맞았다고 단정하지 않습니다. 파일 원바이트와 선언한 인코딩을 함께 보관합니다.
Displayed Korean text and file bytes are different layers. An encoding represents characters as bytes; decoding interprets bytes under that convention. Bytes do not always uniquely identify the intended encoding.
The same text can have different byte counts and hashes across encodings. Conversely, ASCII prefixes can agree across several encodings, so a readable prefix does not establish correct decoding of the whole file. Preserve original bytes and declared encoding.
기초Foundations
34. 같은 사전을 UTF-8과 CP949로 읽는다34. Read the same dictionary in UTF-8 and CP949
실제 고객 관측을 바꾸는 대신, 한글 설명 두 개가 있는 별도 교육용 사전을 만들었습니다. UTF-8 사본은 73바이트, CP949 사본은 63바이트입니다. 각자 선언한 인코딩으로 읽으면 같은 두 변수 설명이 나옵니다. 작은 크기가 더 정확한 자료라는 뜻은 아닙니다.
이 사전에는 한글 음절 10개가 있습니다. 이번 선택 문자들은 UTF-8에서 각각 3바이트, CP949에서 각각 2바이트여서 사본 크기가 10바이트 차이 납니다. 모든 유니코드 문자가 두 인코딩에 들어가거나 항상 같은 바이트 수를 쓴다는 일반화는 하지 않습니다.
A separate teaching dictionary contains two Korean labels; actual customer observations remain unchanged. Its UTF-8 copy uses 73 bytes and CP949 copy 63. Each declared decoder yields the same labels. A smaller file is not necessarily more accurate.
The dictionary has ten Korean syllables. These selected characters use three UTF-8 bytes and two CP949 bytes each, accounting for the ten-byte difference. Do not generalize that every Unicode character is representable in both encodings or uses that fixed width.
기초Foundations
35. 엄격 변환의 실제 실패를 보존한다35. Preserve actual failures of strict decoding
CP949 사전을 UTF-8로 읽은 실제 Python 실행은 바이트 위치 24에서 UnicodeDecodeError를 기록했습니다. 반대로 UTF-8 사전을 CP949로 읽어도 이번 파일은 엄격 변환에 실패했습니다. 이 예에서 원바이트가 사라진 것이 아니라 잘못 선택한 약속으로 읽지 못한 것입니다.
R 예제의 iconv는 이번 변환 실패에서 NA를 반환했고, 작성한 코드가 이를 확인해 명시적 오류로 멈췄습니다. Python과 같은 예외 이름을 지어 붙이지 않습니다. 대체 문자로 계속 읽으면 일부 원문 정보가 사라질 수 있으므로, 그런 정책을 쓴 경우 별도 처리 기록이 필요합니다.
Actual Python execution decoding the CP949 dictionary as UTF-8 recorded UnicodeDecodeError at byte 24. The reverse wrong-decoder experiment also failed for this file. Bytes were not lost; the selected interpretation failed.
R’s iconv returned NA for these conversions, and the written guard explicitly stopped. Do not invent a Python-style exception for R. Replacement characters can discard source information, so a replacement policy requires its own processing record.
기초Foundations
36. UTF-8 BOM은 이 사본에서 추가한 표식이다36. The UTF-8 BOM was added to this working copy
원 고객 CSV는 UTF-8 BOM이 없습니다. 교육용 사본에는 EF BB BF 세 바이트를 앞에 붙였습니다. 원본 131,728바이트와 사본 131,731바이트의 차이는 3이며 고객이 3명 늘어난 것이 아닙니다. 두 파일을 적절히 읽으면 관측 셀은 같습니다.
BOM 처리를 하지 않는 UTF-8 디코딩도 그 바이트를 U+FEFF로 읽을 수 있습니다. 반드시 디코딩 오류가 되는 것은 아닙니다. 첫 머리글 앞의 보이지 않는 문자가 정확한 이름 비교에 영향을 줄 수 있어, 문자 디코딩과 CSV 읽기 도구의 BOM 처리 규칙을 나누어 확인합니다.
The original customer CSV has no UTF-8 BOM. The teaching copy prepends three bytes, EF BB BF. Its size grows from 131,728 to 131,731 bytes without adding customers. Appropriate reading preserves the same observation cells.
Plain UTF-8 decoding can represent the prefix as U+FEFF rather than fail. This invisible character can affect exact header lookup. Distinguish character decoding from any BOM handling performed later by a CSV reader.
기초Foundations
37. Python과 R의 두 단계 BOM 처리를 비교한다37. Compare two-stage BOM handling in Python and R
Python의 보관 실행에서 utf-8-sig는 처음 BOM을 소비해 첫 코드점 67, 첫 머리글 Call Failure를 냈습니다. 일반 utf-8는 첫 코드점 65279를 보존하고 첫 머리글에도 U+FEFF가 남았습니다. 출력 스트림도 UTF-8로 명시해 그 문자를 기록할 수 있게 했습니다.
이 환경의 R 실행은 BOM을 남긴 텍스트의 첫 코드점은 65279였지만, 뒤 read.table이 첫 머리글의 BOM을 별도로 제거했습니다. 두 언어가 반드시 같은 중간 문자열이나 머리글을 만든다고 가정하지 않습니다. 이번 보관 버전·옵션의 실제 결과로 한정해 읽습니다.
In the archived Python run, utf-8-sig consumed the initial BOM, yielding first code point 67 and header Call Failure. Plain utf-8 retained code point 65279 and U+FEFF in that header. Explicit UTF-8 output streams preserved its display record.
In this R environment, the unstripped text began at code point 65279, but the subsequent read.table separately removed the header BOM. Do not assume identical intermediate text/header behavior across languages. These are observations under the recorded versions and options.
기초Foundations
38. 디코딩 성공과 표 읽기 성공도 따로 본다38. Separate successful decoding from successful parsing
인코딩이 맞아 한글이 읽혀도 구분자가 틀리면 표가 틀릴 수 있습니다. 구분자가 맞아 열 수가 기대와 같아도 날짜 형식이나 범주 의미는 틀릴 수 있습니다. 단계마다 통과 조건을 따로 적어야 어디에서 의미가 바뀌었는지 찾을 수 있습니다.
파일 바이트→문자열→CSV 필드→수치·날짜→측정 의미의 사슬을 그려 보세요. 라이브러리가 여러 단계를 내부에서 처리할 수도 있으므로 반드시 줄마다 분리하라는 뜻은 아닙니다. 개념적으로 어떤 계약이 적용되는지 확인하고 원바이트와 원문 필드를 보존합니다.
Correct Korean decoding can coexist with a wrong delimiter. Correct field count can coexist with an unsuitable date format or category interpretation. Separate success conditions at each layer to locate a semantic change.
Trace bytes→text→fields→numerical/date values→measurement meaning. A library may perform several layers internally; this is not a requirement to write one command per layer. Identify the applied contracts and retain original bytes and field text.
기초Foundations
39. 인코딩 선택의 환경 의존성을 적는다39. Record the environment behind an encoding choice
이번 실제 실행은 Python 3.12.14와 Windows R 4.5.1에서 수행했습니다. R의 인코딩 이름 지원과 변환 동작은 플랫폼의 기능도 사용하므로 다른 환경에서 같은 별칭이 항상 지원된다고 가정하지 않습니다. 원자료가 명시한 인코딩과 실제 도구가 사용한 이름을 함께 적습니다.
다운로드한 Python 코드는 stdout·stderr를 UTF-8로 설정하고 R 코드는 이 Windows 실행의 문자 로케일 요청을 포함합니다. 이것은 원자료의 인코딩을 무조건 바꾸는 명령이 아니라 출력과 경로 처리를 명시하는 실행 조건입니다. 입력 파일의 디코더는 코드에서 별도로 선언합니다.
These actual runs used Python 3.12.14 and Windows R 4.5.1. R conversion facilities and supported encoding aliases can depend on the platform. Record the source convention and the tool’s actual encoding name rather than assuming every alias is portable.
Downloaded Python source sets UTF-8 stdout/stderr; R source includes the Windows character-locale request. These execution settings do not automatically transcode every input. Each input decoder is declared separately.
기초Foundations
40. 실습 E: 같은 문자·다른 바이트·다른 실패를 읽는다40. Lab E: inspect equal text, different bytes and different failures
UTF-8/CP949 사전과 추가 BOM 고객 사본을 선택하고 디코더 정책을 비교합니다. 엄격 오류, 원 텍스트의 첫 코드점, 파싱 뒤 첫 머리글을 나누어 읽으세요. BOM 비교에서 일반 UTF-8 선택을 항상 오류라고 표시하지 않습니다.
여기서는 준비한 12개 실제 기록을 선택합니다. 원 고객 관측은 바꾸지 않았고 한글 사전은 설명용 파생 자료입니다. 새로운 파일의 인코딩은 이 몇 개 예제만으로 자동 판별되었다고 말할 수 없습니다.
Select UTF-8/CP949 dictionaries or the added-BOM customer copy and compare decoder policies. Separate strict errors, the text’s first code point and the parsed first header. Plain UTF-8 is not universally labeled an error in the BOM comparison.
The lab selects twelve actual archived runs. Customer observations remain unchanged; the Korean dictionary is derived descriptive metadata. These examples do not automatically determine an unknown file’s encoding.
기초Foundations
41. 실제 BIS 180분기에서 값·기준·범위를 나눈다41. Separate values, reference and coverage in 180 BIS quarters
실제 보관 분기는 1980-Q1부터 2024-Q4까지 45년×4=180개입니다. 실질·명목 지수는 원 소수값을 별도로 보존합니다. 기준은 2010년 평균=100이지만, 실제 공표한 2010년 네 소수값의 평균은 4000113/40000=100.002825입니다. 반올림된 수치의 평균을 재기준 정의와 같은 대상으로 혼동하지 않습니다.
파생 달력 경계는 기간 표시를 돕고, 앞 24개 토지 가격 대용 범위 표지는 측정 범위의 변화를 설명합니다. 지수 107을 주택 가격 107원이나 모든 가구의 지출이라고 읽을 수는 없습니다. 원 지표·지역·범위를 확인해야 합니다.
The retained periods run from 1980-Q1 to 2024-Q4: 45 years times four gives 180. Real and nominal source decimals remain separate. Although the reference is average 2010=100, the four retained reported decimals average 4000113/40000=100.002825. A mean of rounded observations and a construction reference are different objects.
Derived boundaries label periods; the first 24 land-proxy flags explain a coverage change. An index of 107 is not a dwelling price of 107 currency units or every household’s expenditure. Retain indicator, geography and coverage.
기초Foundations
42. 실제 고객 3150행에서 코드·단위·창을 지킨다42. Preserve codes, units and windows in 3150 customer rows
고객 원 CSV는 3,150행·14열입니다. 원 머리글과 분석 이름의 대응을 유지하며 이탈 0/1, 요금제 1/2, 요금 수준 0~9, 연령 집단 1~5를 수량 단위와 구분합니다. Seconds of Use는 초 단위, Subscription Length는 개월 길이로 설명됩니다.
파일의 원행 번호는 이 보관 순서를 추적하는 표식입니다. 고객 실명이나 영구 식별자를 새로 알아낸 것이 아닙니다. 달력 연도가 없는 첫 9개월·12개월 상대 창과 Customer Value의 원 설명 한계도 그대로 남깁니다. 구체적인 예측 누수 점검은 뒤 장으로 이어갑니다.
The source customer CSV has 3,150 rows and 14 fields. Preserve its rename map and distinguish churn 0/1, tariff 1/2, charge-level 0–9 and age-group 1–5 codes from measurement units. Seconds of Use is duration in seconds; Subscription Length is duration in months.
A source-row number traces this archived order; it does not newly identify a person or permanent customer key. Retain relative first-nine/month-twelve windows without invented years and limits of the Customer Value definition. Later chapters examine prediction leakage in detail.
기초Foundations
43. 1599개 레드 기록을 새 기업 관측으로 바꾸지 않는다43. Do not turn 1599 red records into identified firms
와인 파일은 레드 부분집합 1,599행·12열이며 화이트 부분집합과 섞지 않습니다. 세미콜론·따옴표 머리글·소수점 점이라는 저장 약속을 지켜 읽습니다. 열 11개는 이화학 변수이고 quality는 평가 점수입니다. 확인되지 않은 화학 단위를 덧붙이지 않습니다.
실제 quality 3~8의 빈도는 각각 10,53,681,638,199,18로 합이 1,599입니다. 알려진 가능한 점수 범위와 실제 관측 범위는 다릅니다. 숫자 조합이 같은 반복이 있어도 브랜드·기업·포도 품종·개별 병의 영구 ID가 없어 같은 관측을 잘못 입력했다고 단정하지 않습니다.
The red subset has 1,599 records and twelve fields; keep it distinct from white wine. Respect semicolons, quoted headers and decimal dots. Eleven columns are physicochemical variables and quality is an evaluation score. Do not add unverified chemical units.
Observed scores 3–8 have counts 10,53,681,638,199,18, totaling 1,599. Possible and observed ranges differ. Repeated numerical combinations do not alone establish erroneous duplicate observations without brand, firm, grape or persistent bottle identifiers.
기초Foundations
44. 읽기 계약을 짧은 보고서로 남긴다44. Retain a short import contract report
한 파일의 읽기 보고서에는 출처·입력 해시·실제 저장 형식·인코딩·구분자·소수점·인용·머리글·결측 규칙을 적습니다. 원행 수·열 수·변수명 대응과 단위·시간 해석도 연결합니다. 어떤 값은 관측이고 어떤 값은 파생 날짜나 교육용 코드인지 표시합니다.
검사 통과의 범위를 명시하세요. 이번 파일 전 셀 비교와 44개 고정 실행은 유용한 근거지만, 모든 미래 파일·모든 운영체제·모든 도구의 동작에 대한 증명은 아닙니다. 원 측정 정확성이나 인과·대표성은 별도 질문입니다.
An import report states provenance, input hash, serialization, encoding, delimiter, decimal mark, quoting, header and missing rules. Link row/field counts, rename map, units and time meaning. Mark observations separately from derived dates or teaching labels.
Specify check scope. Whole-cell comparison of these files and 44 fixed runs provide evidence, not a proof for every future file, platform or tool. Measurement accuracy, causality and representativeness remain separate questions.
심화Extension
45. 심화: 정보를 버리는 변환은 자동 역변환되지 않는다45. Advanced: information-losing transforms need not be reversible
두 원 열 이름의 공백을 지워 같은 이름으로 만들면 대응 정보가 사라질 수 있습니다. 원래 미관측과 빈 문자열을 같은 빈 필드로 내보내면 어느 쪽이었는지 결과 파일만으로 복원하지 못할 수 있습니다. 변환 함수가 서로 다른 입력을 같은 출력으로 보내기 때문입니다.
따라서 정규화 규칙을 쓰더라도 원바이트·원문·출처 키·대응표를 별도로 보존합니다. 되돌릴 수 있는 단위 배수와 정보를 버리는 이름 합치기·무조건 결측 대체는 다른 연산입니다. 다음 장의 정제에서는 편리한 처리와 근거 있는 처리의 차이를 더 자세히 다룹니다.
Removing spaces can merge two source headers. Exporting both missingness and an empty string as the same empty field can prevent recovery from the output alone. Such a map sends distinct inputs to one output.
Preserve original bytes/text, provenance keys and maps even when applying normalization. An invertible unit scale differs from lossy name merging or unconditional missing-value replacement. The next chapter develops the distinction between convenient and justified cleaning.
기초Foundations
46. 실습 F: 원행과 메타데이터를 함께 읽는다46. Lab F: inspect source rows together with metadata
BIS 분기·고객·와인 기록을 선택해 원행과 사전을 함께 확인합니다. 원행 순서의 번호를 새 측정 시각으로 읽지 않고, 내부 모델의 person/company라는 이름을 실명·기업 식별 정보로 읽지도 않습니다.
화면은 고정 공개 기록을 조회합니다. 다른 행으로 이동해도 원파일을 수정하거나 새 관측을 추가하지 않습니다. 필요한 처리라면 다음 장에서 명시적 작업 사본과 검사로 수행합니다.
Select BIS periods, customer rows or wine records and inspect metadata beside source values. A row-order index is not a new timestamp, and internal person/company model names do not identify actual named people or firms.
This view queries retained public records. Selecting another row neither changes a source file nor creates observations. Later cleaning uses declared working copies and checks.
기초Foundations
47. 실제 국가·고객·제품 사례와 원문을 읽는다47. Read actual country, customer and product cases
국가 사례 · 분기 지수를 날짜와 원화 가격으로 오해하지 않기
BIS 한국 주택 관련 지수의 보관 사본 180분기(1980년 1분기~2024년 4분기)를 원문 값과 대조했습니다. 로컬 파일 이름은 .csv로 끝나지만 실제 첫 바이트는 XML 선언이고 관측값은 SDMX XML의 TIME_PERIOD·OBS_VALUE 속성에 들어 있습니다. 확장자만 믿고 쉼표로 읽지 않습니다. 데이터 형식·지역 KR·주기 Q·명목/실질 계열을 먼저 확인한 뒤 분석용 CSV를 새로 만들었습니다.
원 분기 표지와 계산한 달력 경계 · 원 소수 보존
분기
달력 시작
달력 끝
실질 지수
명목 지수
1980-Q1
1980-01-01
1980-03-31
104.396
23.1287
1986-Q1
1986-01-01
1986-03-31
120.9882
42.3793
2010-Q1
2010-01-01
2010-03-31
100.496
99.5078
2024-Q4
2024-10-01
2024-12-31
107.4756
142.6825
분기 시작·끝은 분기 표지에서 계산한 달력 경계입니다. 예를 들어 2024-Q4를 2024-12-31이라는 실제 거래 시각이나 측정일로 바꾸지 않습니다. BIS의 설명은 분기 계열을 월 관측의 평균으로 설명하며 계열마다 원자료·연장 방식이 다를 수 있다고 밝힙니다. 더 중요한 범위 차이도 있습니다. 공식 한국 메타데이터에서 1986년 1분기 이후는 기존 주택 가격 계열이고 이전 구간은 주거·비주거 토지 가격의 역사적 대용 계열입니다. 180행을 모두 같은 주택 표본의 연속 측정이라고 해석하지 않습니다.
명목·실질 값은 모두 2010년 평균=100이라는 기준 지수이며 원화 가격이 아닙니다. 실질 지수는 소비자물가로 조정한 계열입니다. 보관본에 실린 2010년 네 실질 값은 100.496, 100.3475, 99.5085, 99.6593이고 평균은 정확히 100.002825입니다. 메타데이터의 기준 100과 보관된 분기 숫자의 평균을 구별해 그 작은 차이를 숨기거나 원인을 추측하지 않습니다.
먼저 생각한 뒤 풀이 보기: 2024년 4분기 실질 지수 107.4756은 107.4756원 또는 직전 분기 대비 7.4756% 상승인가요?
둘 다 아닙니다. 기준 100에 대한 지수 수준입니다. 기준 100보다 7.4756% 높다는 산술 비교는 가능하지만 직전 분기 상승률은 그 직전 분기 지수를 분모로 해야 합니다. 주택 한 채의 가격이나 개별 가구의 이익도 이 값만으로 계산할 수 없습니다.
먼저 생각한 뒤 풀이 보기: 분기 끝 날짜를 만들었으니 일별 그래프로 90개 값을 채워도 되나요?
아닙니다. 달력 경계는 새로운 일별 관측을 만들지 않습니다. 보간하려면 별도 가정을 명시해야 합니다. 이 장은 원 분기 수준만 표시하며 역사적 범위 차이를 메타데이터와 함께 보존합니다.
고객 사례 · 이중 공백 머리글, 문자 인코딩, 상대 시간창
공개 UCI Iranian Churn 원 ZIP 안의 CSV는 실제 고객 기록 3,150행·14열입니다. 이 고객은 특정 이름을 공개한 개인이 아니며 원행 번호는 추적용 위치입니다. 원 머리글에는 Call Failure·Subscription Length처럼 공백 두 개가 있습니다. 원 필드 이름을 그대로 보존하고 새 분석 이름을 대응표에 적습니다. 공백을 줄이고 소문자로 만드는 규칙을 적용한 뒤 14개 이름이 여전히 서로 다른지도 검사했습니다. 이름을 바꾸는 일과 실제 값을 바꾸는 일은 다릅니다.
코드와 단위를 사전으로 구별하는 실제 열
원 열
분석 열
사전의 뜻
단위·코드
Complains
complains
불만 접수 코드
0=불만 없음, 1=불만 있음
Subscription Length
subscription_length
가입 기간
개월
Charge Amount
charge_amount
요금 수준 코드
0~9 순서 코드 · 통화액 아님
Age Group
age_group
연령 집단 코드
1~5 순서 코드 · 실제 나이 아님
Churn
churn
이탈 여부
0=비이탈, 1=이탈
Charge Amount의 0~9는 요금 수준의 순서 코드이지 원·리알 같은 통화액이 아닙니다. Age Group의 1~5도 나이 자체가 아닙니다. 구독 기간의 월 수, 사용 시간의 초, 이탈의 0/1은 서로 다른 측정 척도입니다. UCI 설명은 앞 9개월의 속성과 12개월 시점의 이탈 결과, 그 사이 3개월 간격을 제시합니다. 실제 달력 시작일은 주지 않으므로 자료 공개 연도 2020을 고객 관측 연도로 붙이지 않습니다. customer_value를 임의로 통화 수익으로 읽지도 않습니다.
원 CSV 바이트에는 UTF-8 BOM이 없습니다. 수업용으로 같은 바이트 앞에 BOM 세 바이트만 붙인 작업 사본을 별도로 만들었습니다. utf-8-sig로 두 파일을 읽으면 같은 3,150×14 셀이 되지만 BOM 사본을 단순 utf-8로 읽으면 첫 머리글 앞에 보이지 않는 U+FEFF가 남습니다. 원본에 BOM이 있었다고 기록하지 않습니다. 원 자료가 ASCII 범위 문자만 담았다는 점도 중요합니다. 여러 인코딩에서 같은 모양으로 열릴 수 있어 그것만으로 문자인코딩을 유일하게 알아낸 것은 아닙니다.
# Paths refer to the separately supplied data04-sources files.
import csv
with open('actual-original-churn-no-BOM.csv', encoding='utf-8-sig', newline='') as f:
rows = list(csv.DictReader(f))
assert len(rows) == 3150
assert len(rows[0]) == 14
assert 'Call Failure' in rows[0]
먼저 생각한 뒤 풀이 보기: 깨진 한글을 errors="ignore"로 열어 정상 파일로 저장하면 해결될까요?
문자를 조용히 버릴 수 있어 해결로 볼 수 없습니다. 제공한 한글 변수 설명 작업 사본은 실제 측정값이 아니라 파생 사전입니다. 같은 설명을 UTF-8과 CP949로 저장하고, CP949 사본을 엄격한 UTF-8로 읽으면 실제 UnicodeDecodeError가 생기는지 확인했습니다. 맞는 인코딩으로 읽으면 설명이 같습니다. 오류를 숨기기보다 원본 바이트를 보존하고 디코더·BOM·실패 기록을 남기세요.
먼저 생각한 뒤 풀이 보기: 이탈 코드 0이 많으니 0을 결측으로 바꾸면 분석이 편해질까요?
아닙니다. 이 사전에서 0은 실제 비이탈 범주이며 495개 이탈과 2,655개 비이탈을 함께 보존해야 합니다. 결측 표지는 열별 원 설명을 확인해 정하며 숫자 0이나 빈 문자열을 모든 열에서 같은 뜻으로 처리하지 않습니다.
제품 실무 사례 · 세미콜론을 틀리면 12열이 1열이 된다
UCI Wine Quality의 포르투갈 Vinho Verde 레드 와인 1,599행을 원 ZIP에서 그대로 읽습니다. 관측 단위는 제공된 제품·실험실 측정 기록이며 제조 기업이나 브랜드가 식별돼 있지 않습니다. 특정 기업의 제품군 또는 독립적으로 뽑은 1,599개 기업이라고 바꾸지 않습니다. 같은 개체의 반복 측정 여부도 원 자료가 보장하지 않습니다. 이 사례는 자료 입출력 실무이지 와인 소비 권고가 아닙니다.
파일은 따옴표로 감싼 머리글과 세미콜론 구분자, 소수점 점을 사용합니다. 실제 첫 머리글을 쉼표 구분자로 읽으면 열이 하나이고, 세미콜론으로 읽으면 12열입니다. 파일이 열리고 행 수가 1,599라고 나오는 것만으로 올바른 import가 아닙니다. 품질 열과 예상 열 이름·자료형·범위까지 확인해야 합니다. 이 파일에 R의 read.csv2를 기본값 그대로 적용하면 소수점 쉼표 규칙까지 따라갈 수 있으므로 sep=";", dec="."를 명시합니다.
import csv
with open('actual-original-winequality-red-semicolon.csv', encoding='utf-8', newline='') as f:
wine = list(csv.DictReader(f, delimiter=';'))
assert len(wine) == 1599 and len(wine[0]) == 12
assert 'quality' in wine[0]
# Convert only after checking the source field and units.
실제 처음 세 제품 기록 · 원 소수 그대로
원행 키
alcohol 원 값
density 원 값
pH 원 값
품질 점수
1
9.4
0.9978
3.51
5
2
9.8
0.9968
3.2
5
3
9.8
0.997
3.26
5
품질 점수는 원 설명에서 0~10 순서 척도이며 최소 3명 전문가 평가의 중앙값입니다. 이 레드 와인 사본에는 실제로 3~8점만 나타납니다. 그 차이가 같다고 가정하는 평균·제곱손실은 별도 수치 모형 선택입니다. CSV의 열 이름과 함께 보관한 names 파일은 화학 측정 열의 모든 단위를 싣고 있지 않습니다. 단위를 확인하기 전에 숫자를 자동으로 퍼센트·g/L로 변환하지 말고 측정 방법 원문과 사전을 추가 확인해야 합니다. 모르는 단위를 아는 것처럼 채우는 것보다 미확인 상태를 명시하는 편이 정확합니다.
실제 레드 와인 품질 점수 빈도
점수
제품 기록 수
3
10
4
53
5
681
6
638
7
199
8
18
먼저 생각한 뒤 풀이 보기: 12개 열 모두 숫자처럼 보이면 한 번에 수치 행렬로 읽고 사전을 생략해도 되나요?
아닙니다. 숫자 모양은 단위·범주·시점·결측 규칙을 알려 주지 않습니다. 이 파일의 quality는 순서 점수이고, 고객의 charge_amount는 코드이며, 주택의 107.4756은 지수입니다. 숫자 변환 전에 그 숫자가 무엇을 세거나 측정하는지 확인하세요. 제품 예측 상관은 성분을 조작했을 때의 인과효과도 아닙니다.
Country case · A quarter index is neither a transaction date nor a currency price
Check all 180 archived Korean BIS housing-related quarters, 1980 Q1–2024 Q4, against the source. Although the local filename ends in .csv, its bytes begin with an XML declaration and observations occupy TIME_PERIOD/OBS_VALUE attributes in SDMX XML. Do not choose a comma parser from the extension alone. Verify serialization, region KR, quarterly frequency Q and nominal/real series before making an analysis CSV.
Quarter starts/ends are calendar boundaries calculated from period labels, not measured transaction timestamps. A label such as 2024-Q4 does not establish an actual observation on December 31. BIS describes quarterly indices as averages of monthly observations and notes differences in source/extension methods. Its Korea metadata identifies existing-dwelling prices from 1986 Q1 and an earlier residential/nonresidential land-price proxy. Do not treat all 180 rows as homogeneous measurements of one unchanged dwelling sample.
Nominal and real values are indices referenced to average 2010=100, not prices in Korean won. The real series is CPI-deflated. The archived four 2010 real values are 100.496, 100.3475, 99.5085 and 99.6593, whose exact average is 100.002825. Distinguish the stated reference 100 from the mean of the retained reported decimals; neither hide their small discrepancy nor invent its cause.
Think first, then reveal: Does the 2024 Q4 real index 107.4756 mean 107.4756 won or a 7.4756% quarter-on-quarter increase?
Neither. It is an index level relative to reference 100. It is arithmetically 7.4756% above that reference, but quarter-on-quarter growth requires the previous quarter as denominator. It does not directly price a dwelling or measure household gains.
Think first, then reveal: After calculating a quarter-end date, may we fill ninety daily observations?
No. Calendar boundaries create no new daily measurements. Interpolation requires an explicit separate model. This case plots only original quarterly levels and retains the historical coverage distinction.
Customer case · Double-space headers, encodings and relative time windows
The public UCI Iranian Churn ZIP contains 3,150 actual customer records and fourteen fields. These are not named identifiable individuals; our source row numbers trace file positions. Headers such as Call Failure and Subscription Length contain two spaces. Preserve the original names and an explicit mapping to analysis names. After collapsing spaces and lowercasing, verify that all fourteen names remain distinct. Renaming fields does not change their actual values.
Actual fields whose codes and units require a dictionary
Source field
Analysis field
Dictionary meaning
Unit/code
Complains
complains
Complaint indicator
0=no complaint, 1=complaint
Subscription Length
subscription_length
Subscription length
Months
Charge Amount
charge_amount
Charge-level code
Ordered codes 0–9 · not currency
Age Group
age_group
Age-group code
Ordered codes 1–5 · not age in years
Churn
churn
Churn indicator
0=nonchurn, 1=churn
Charge Amount values 0–9 are ordered charge-level codes, not amounts in won or rials. Age Group codes 1–5 are not ages in years. Subscription months, seconds of use and binary churn have different scales. UCI describes first-nine-month attributes, a month-twelve churn outcome and a three-month gap. It supplies no calendar origin, so the release year 2020 is not a customer observation year. Do not arbitrarily label customer_value as currency revenue.
The original CSV bytes have no UTF-8 BOM. Make a separately named teaching copy that adds only the three BOM bytes. Reading both with utf-8-sig gives the same 3,150×14 cells; plain utf-8 leaves an invisible U+FEFF before the first header in the BOM copy. Do not attribute that added BOM to the original. Because the original uses the ASCII subset, several compatible decoders can display it identically; successful display alone does not uniquely identify its encoding.
# Paths refer to the separately supplied data04-sources files.
import csv
with open('actual-original-churn-no-BOM.csv', encoding='utf-8-sig', newline='') as f:
rows = list(csv.DictReader(f))
assert len(rows) == 3150
assert len(rows[0]) == 14
assert 'Call Failure' in rows[0]
Think first, then reveal: Does reading broken text with errors="ignore" and saving it solve the problem?
No: it can silently discard characters. The supplied Korean-label working copies are derived dictionaries, not measurements. Save the same labels as UTF-8 and CP949 and verify that strict UTF-8 decoding of the CP949 copy raises a real UnicodeDecodeError. Correct decoders recover equal labels. Preserve original bytes and record the decoder, BOM and failures instead of hiding them.
Think first, then reveal: Would replacing the many zero churn codes with missing values simplify analysis?
No. Here zero is the valid nonchurn category. Preserve 495 churn and 2,655 nonchurn records. Determine missing markers from each field’s source definition rather than assigning one meaning to zero or empty text everywhere.
Product practice case · The wrong delimiter turns twelve fields into one
Read 1,599 Portuguese Vinho Verde red-wine records directly from the UCI ZIP. Units are supplied product/laboratory measurement records, without identified producer firms or brands. Do not relabel them as one named company’s portfolio or 1,599 independent firms. The source does not establish whether records include repeated measurements of the same item. This is a data-import practice case, not a consumption recommendation.
The file uses quoted headers, semicolon delimiters and decimal points. Parsing its actual header with commas produces one field; semicolons produce twelve. Merely opening a file and seeing 1,599 rows does not establish correct import. Check expected names, quality field, types and ranges. R read.csv2 also changes the default decimal convention, so explicitly specify sep=";" and dec="." for this file.
Actual first three product records · source decimals retained
Source row key
Source alcohol value
Source density value
Source pH value
Quality score
1
9.4
0.9978
3.51
5
2
9.8
0.9968
3.2
5
3
9.8
0.997
3.26
5
The source describes quality as an ordered 0–10 score, the median of at least three expert evaluations; this red-wine copy contains scores 3–8. Treating score differences as equal for means or squared loss is a separate numeric modeling choice. CSV headers and the retained names file do not document every chemical-field unit. Do not automatically convert values to percentages or g/L before checking primary measurement methods and a dictionary. Explicitly recording an unverified unit is more accurate than inventing it.
Actual red-wine quality frequencies
Score
Product records
3
10
4
53
5
681
6
638
7
199
8
18
Think first, then reveal: If all twelve columns look numeric, may we skip the dictionary and read a numeric matrix immediately?
No. Numeric appearance does not supply units, categories, timing or missing rules. Wine quality is ordered, customer charge_amount is a code, and housing 107.4756 is an index. Establish what each number measures before conversion. Product prediction associations also do not establish effects of manipulating ingredients.
기초Foundations
48. 공식 문서로 읽기 계약을 다시 설명한다48. Explain the import contract using primary documentation
Python CSV 문서의 reader·newline·구분자·인용 설명을 실제 코드와 비교하세요. datetime 문서에서는 날짜 생성과 형식 해석, 시각의 시간대 정보 차이를 확인합니다. 문서의 현재 패치 버전과 보관 실행 3.12.14는 구별합니다.
R read.table 문서에서는 sep·dec·quote·check.names·colClasses를, iconv 문서에서는 from·to·sub와 플랫폼 한계를 읽습니다. 웹의 개발판 문서가 이번 R 4.5.1의 모든 구현을 그대로 설명한다고 가정하지 않고 실제 보관 결과를 함께 확인합니다.
원자료의 의미는 도구 문서가 아니라 BIS·UCI 원자료 설명과 자료사전에서 찾습니다. 한 파일을 골라 바이트부터 관측표까지의 계약과 아직 모르는 메타데이터를 동료에게 설명하세요. 다음 장은 결측·중복·이상값을 표시하고 정리할 때 원자료를 보존하는 방법으로 이어집니다.
Compare actual code with reader, newline, delimiter and quoting guidance in the Python CSV documentation. Use datetime for date construction, format interpretation and time-zone distinctions. Distinguish the website’s patch release from archived Python 3.12.14.
Read sep, dec, quote, check.names and colClasses in R read.table, and from, to, sub and platform limitations in iconv. Development-manual content is not assumed to describe every detail of recorded R 4.5.1; inspect the actual runs too.
Tool documentation does not establish source meaning; consult BIS/UCI descriptions and dictionaries. Explain one file’s bytes-to-table contract and still-unknown metadata to a colleague. Next come missingness, duplicates, outlier flags and source-preserving cleaning.
자료 묶음을 풀고 코드와 실제데이터 폴더를 함께 두세요. 터미널에서 코드 파일이 있는 폴더로 이동해 아래 명령을 실행합니다. 코딩이 처음이라면 손계산과 웹 실습을 먼저 하고, 데이터 사이언스 입문에서 코드를 배운 뒤 돌아와도 됩니다.Extract the bundle, keeping the scripts beside the data folder. In a terminal, enter the script folder and run the commands below. Beginners can complete hand calculations and browser labs first, returning to code after studying introductory data science.
결과 파일은 각 코드에 지정된 결과 폴더에 저장됩니다. CSV 원자료는 덮어쓰지 않습니다.Result files are saved in the result directory specified by each script; the input CSVs are not overwritten.
영상·학자·함께 읽기Videos, thinkers and guided reading
본문의 질문을 넓히는 선택 학습입니다. 영상을 보기 전 질문을 먼저 읽고, 자신의 답을 쓴 뒤 해설과 비교하세요. 자료의 언어·선수 지식은 각 항목에 표시했습니다.Optional extensions to the chapter. Read the question first, write your answer, then compare with the explanation. Language and prerequisites are indicated below.
MIT · 자료를 읽은 뒤 결측을 먼저 확인하기MIT · Check missing values after importing data
MIT 15.071 · The Analytics Edge · 2017 · official lesson
자료를 읽은 뒤 결측을 확인하는 과정을 본문의 import 계약과 연결합니다. 빈 값·범주 코드·열 자료형을 확인하는 단계에 집중하고, 영상에 등장하는 결측 처리법을 모든 자료에 자동 적용하지 않습니다.Connect the lesson’s missing-data checks to the import contract. Focus on missing markers, codes and column types; do not automatically apply a demonstrated treatment to every dataset.
교재 안의 YouTube 플레이어에서 재생합니다. 원영상에서 제공하는 자막은 플레이어의 CC·설정에서 선택할 수 있습니다.Playback stays in this chapter’s YouTube player. Available captions can be selected through CC/settings.
보고 읽은 뒤 답하기Respond after watching/reading0 코드와 빈 값은 언제나 같은 뜻인가요?Do a zero code and an empty value always mean the same thing?
생각을 점검하는 해설Check your reasoning
아닙니다. 이탈 열의 0은 비이탈 범주이며 결측 뜻은 원 자료 사전과 열별 계약으로 정합니다.No. Zero in churn denotes nonchurn. Missing meanings come from the source dictionary and each field’s contract.
해들리 위컴 · 도구와 자료 설명을 함께 설계하기Hadley Wickham · Design tools together with data explanations
Posit · official profile
tidyverse 도구를 만든 연구자의 소개를 읽고 자료를 빠르게 읽는 일과 의미를 정확히 보존하는 일을 함께 생각해 보세요. 편리한 자동 추측에도 사전·단위·원본 확인이 필요합니다.Read the toolmaker’s official account and consider both convenient import and preserving meaning. Automatic guessing still requires dictionaries, units and source checks.
보고 읽은 뒤 답하기Respond after watching/reading자동 이름 정리가 성공하면 자료 뜻도 자동으로 확인됐나요?Does successful automatic name repair establish the data meaning?
생각을 점검하는 해설Check your reasoning
아닙니다. 충돌·원 이름 대응·코드와 단위·시점을 별도로 확인해야 합니다.No. Check collisions, original-name mappings, codes, units and timing separately.
Python 공식 · CSV의 구분자·따옴표·문자열Official Python · CSV delimiters, quoting and strings
Python 3.12 csv · reader and dialects
reader가 기본적으로 문자열을 내놓는다는 설명과 delimiter·quotechar·newline 규칙을 읽습니다. 세미콜론 와인을 실제로 읽고 열 수를 검사하세요. 자동 dialect 추측은 확인할 가설로 다룹니다.Read default string output, delimiter/quotechar and newline handling. Import the actual semicolon wine file and verify its width. Treat dialect guessing as a hypothesis to check.
보고 읽은 뒤 답하기Respond after watching/reading파일을 읽을 때 오류가 없으면 올바른 열 구조인가요?Does absence of a read error establish correct field structure?
생각을 점검하는 해설Check your reasoning
아닙니다. 잘못된 쉼표 규칙으로 와인 12열이 오류 없이 1열로 읽힙니다.No. A wrong comma rule can read twelve wine fields as one without raising an error.
R for Data Science · 자료 읽기와 열 자료형R for Data Science · Import and column types
Authors official book · §7.2 and §7.3
머리글·결측 표지·열 자료형의 명시를 중심으로 읽습니다. readr의 예를 base R 재현 코드와 같은 함수라고 혼동하지 말고 구분자·소수점·문자열 코드라는 공통 계약을 비교하세요.Focus on headers, missing markers and explicit column types. readr examples are not the base R functions in our companions; compare their shared contracts for delimiter, decimal mark and textual codes.
보고 읽은 뒤 답하기Respond after watching/readingCSV를 다시 저장하면 열 자료형도 함께 보존되나요?Does saving CSV preserve its column types?
생각을 점검하는 해설Check your reasoning
아닙니다. CSV는 텍스트 표이므로 다시 읽을 때 열 계약을 적용해야 합니다.No. CSV is a text table, so reapply a column contract on reading.
연습문제 · 계산에서 설명과 증명까지Exercises: calculation, explanation and proof
먼저 혼자 풀고 풀이를 여세요. 숫자와 함께 단위·포함 기준·계산 이유를 확인하세요.Attempt each problem before opening its solution. Check units, inclusion rules and the reason for the calculation.
1. csv라는 이름의 XMLXML with a csv suffix
보관 파일의 이름은 housing.csv인데 첫 내용이 XML 선언이고 Obs 태그를 가집니다. CSV reader로 읽기 전에 무엇을 확인해야 하나요?
A retained file is named housing.csv but starts with an XML declaration and contains Obs tags. What should be checked before using a CSV reader?
풀이와 확인할 이유Solution and explanation
확장자와 실제 저장 구조를 구분합니다. 이번 자료는 SDMX XML이므로 그 구조의 reader와 메타데이터를 사용합니다. 이름을 .xml로 바꾼 작업 사본은 같은 바이트의 사본이지 표 형식으로 변환한 새 자료가 아닙니다.
Distinguish its name from serialization. Use the SDMX XML structure and metadata. A byte-identical .xml working copy is a renamed copy, not conversion into a new table format.
2. 복사와 변환Copying versus conversion
원 BIS XML을 바이트 그대로 복사하고 파일명만 바꿨습니다. 원 관측을 CSV로 변환했다고 말해도 되나요?
You copy the BIS XML bytes unchanged under another name. Has the data been converted to CSV?
풀이와 확인할 이유Solution and explanation
아닙니다. 내용 구조는 여전히 XML입니다. 변환은 관측 필드·메타데이터를 어떻게 표로 표현할지 별도 규칙이 필요합니다. 사본의 해시가 같다는 사실도 구분해서 기록합니다.
No. Its structure remains XML. A conversion requires explicit rules mapping observations and metadata to fields. Record byte-copy identity separately.
3. 인용된 쉼표A quoted comma
가정 CSV의 한 행이 Alice,"Seoul, Korea"이고 선언한 구분자는 쉼표·인용은 큰따옴표입니다. 필드는 몇 개인가요?
A toy CSV row is Alice,"Seoul, Korea" with comma separation and double-quote quoting. How many fields are there?
풀이와 확인할 이유Solution and explanation
두 개이며 두 번째 값은 Seoul, Korea라는 한 문자열입니다. 따옴표 안 쉼표를 새 필드 구분자로 세지 않습니다. 모든 쉼표에서 단순 분할하면 이 계약과 다릅니다.
Two. The second value is the single string Seoul, Korea. Its quoted comma does not delimit another field. Splitting on every comma violates this contract.
4. 줄 수와 행 수Lines and records
머리글 1줄, Alice 1줄, 두 줄 메모를 가진 Bob 2줄, Zero 1줄인 가정 CSV입니다. 선언한 reader의 데이터 행 수와 물리 줄 수를 구하세요.
A toy CSV has one header line, Alice on one line, Bob with a two-line quoted note, and Zero on one line. Count physical lines and data records.
풀이와 확인할 이유Solution and explanation
물리 줄은 5개지만 데이터 기록은 Alice·Bob·Zero 세 개입니다. 머리글은 관측에서 제외하고 Bob의 인용된 줄바꿈은 같은 필드 안에 둡니다.
There are five physical lines but three data records. Exclude the header from observations and retain Bob’s quoted newline within its field.
5. 세미콜론과 소수점 점Semicolons and decimal dots
실제 와인 행은 세미콜론 구분자와 소수점 점을 사용합니다. 세미콜론 파일이므로 자동으로 소수점도 쉼표라고 정해도 되나요?
The actual wine source uses semicolons and decimal dots. Does semicolon separation imply decimal commas?
풀이와 확인할 이유Solution and explanation
안 됩니다. 필드 구분자와 한 수의 소수점 표지는 독립된 약속입니다. 실제 입력에 맞춰 각각 선언하며 R 함수의 기본값만으로 원 자료사전을 대신하지 않습니다.
No. Field separation and decimal notation are independent conventions. Declare both from the source instead of substituting a reader’s defaults for metadata.
6. 1열도 폭 검사를 통과한다A one-field table can pass width checks
실제 12열 와인을 쉼표로 잘못 읽었더니 모든 데이터 행이 1열입니다. 모든 행 폭이 같으므로 올바른 읽기인가요?
A wrong comma import of twelve-field wine data yields one field in every row. Does equal width establish correctness?
풀이와 확인할 이유Solution and explanation
아닙니다. 일관된 잘못된 표도 폭 검사를 통과합니다. 기대 열 수 12, 원 머리글, 원값과 함께 대조합니다. 새 모집단이 관측된 것이 아니라 파싱 설정이 틀린 것입니다.
No. Consistently wrong tables can pass that check. Compare expected twelve fields, source headers and values. This is a parsing difference, not a new population.
7. 읽기와 숫자 변환Reading and numeric conversion
Python csv.reader가 문자열 "1.9"를 반환했습니다. 이 단계에서 이미 float 자료형과 화학 단위가 확인되었나요?
Python csv.reader returns text "1.9". Have floating type and chemical units already been established?
풀이와 확인할 이유Solution and explanation
둘 다 아닙니다. 문자열 읽기, 수치 변환, 측정 단위 확인은 다른 단계입니다. 변환 성공도 출처에 없는 단위를 만들어 주지 않습니다.
No. String reading, numerical conversion and unit identification are distinct. Even successful conversion cannot establish units absent from the source.
8. 다른 언어의 잘못된 읽기Different wrong imports
같은 가정 인용 CSV를 잘못된 구분자로 읽어 Python은 4행, R은 3행을 냈습니다. 둘 중 큰 수가 더 많은 실제 관측이라는 뜻인가요?
With a wrong delimiter, Python returns four rows and R three for the quoted toy CSV. Does the larger count mean more observations?
풀이와 확인할 이유Solution and explanation
아닙니다. 원 가정 기록은 세 개이고 다른 인용·reader 동작이 잘못된 표를 만든 것입니다. 각 옵션과 실제 문자열 처리를 조사합니다. 언어 이름만으로 모든 입력의 정확성을 판단하지 않습니다.
No. The toy source has three logical records. Different reader/quoting behavior produced different parses. Inspect actual options and text; a language name does not certify all imports.
9. 머리글의 두 공백Two spaces in a header
원 고객 열은 Call Failure인데 코드가 Call Failure를 찾습니다. 눈에는 비슷하니 같은 키로 처리해도 되나요?
The source field is Call Failure, but code looks up Call Failure. May visually similar strings be treated as identical keys?
풀이와 확인할 이유Solution and explanation
정확한 문자열은 다릅니다. 원 이름을 보존하고 명시적 분석 이름 대응표를 만듭니다. 원 공백을 몰래 바꾼 뒤 원문이라고 부르지 않습니다.
They differ under exact lookup. Preserve the source name and use an explicit analysis-name map. Do not silently modify a header and describe it as original.
10. 공백 제거의 충돌A collision after removing spaces
열 A B와 AB에서 모든 공백을 지우면 무엇이 문제인가요?
What happens when every space is removed from headers A B and AB?
풀이와 확인할 이유Solution and explanation
둘 다 AB가 되어 서로 다른 원 열의 대응이 충돌합니다. 분석 이름의 유일성과 원 이름 대응을 검사하고 충돌을 명시적으로 해결해야 합니다.
Both become AB. Check uniqueness and source correspondence, then resolve the collision explicitly rather than losing one field’s identity.
11. 요금 코드 0Charge code zero
고객 요금 수준 코드는 0~9이고 관측값이 0입니다. 미관측이라서 제거하거나 0달러라고 불러도 되나요?
The charge-level domain is zero through nine and an observed value is zero. May it be dropped as missing or called zero dollars?
풀이와 확인할 이유Solution and explanation
둘 다 근거가 없습니다. 0은 선언한 범주의 유효 코드입니다. 통화 단위가 없는 수준 코드와 결측 표식·실제 요금 금액을 구별합니다.
Neither follows. Zero is a valid declared category. Distinguish a level code from missingness and an actual monetary amount.
12. 연령 집단의 평균A mean age-group code
Age Group이 1과 5인 두 기록의 평균 코드는 3입니다. 평균 나이가 3세라고 말할 수 있나요?
Two Age Group codes are one and five, averaging three. Does that establish mean age three years?
풀이와 확인할 이유Solution and explanation
안 됩니다. 집단 코드 평균은 나이 단위 평균이 아닙니다. 범주 경계·분포나 실제 나이 변수가 더 필요합니다. 저장 수치의 산술과 측정 의미를 구별합니다.
No. An average group code is not a mean in years. Additional group boundaries/distributions or actual age measurements are needed.
13. 불만 0과 빈 칸Complaint zero and a blank
가정 불만 코드가 0,1,빈 칸입니다. 0은 불만 없음이고 빈 칸만 미관측이라면 가용 분모와 불만 비율은요?
Toy complaint codes are 0,1, blank. Zero means no complaint and only blank is missing. Find the available denominator and complaint share.
풀이와 확인할 이유Solution and explanation
가용 2개 중 불만 1개이므로 1/2입니다. 0도 버리면 분모가 1로 바뀌어 잘못 100%가 됩니다. 이 가정 예를 실제 무결측 고객 파일에 새 결측이 있다는 주장으로 쓰지 않습니다.
One complaint among two available codes gives 1/2. Dropping zero changes the denominator and falsely produces 100%. This toy example does not add missingness to the actual retained customer file.
14. 질문에 맞는 사전A dictionary suited to the question
사전에 원 변수명·단위만 있고 집계 기간이 없습니다. 같은 단위의 두 열을 바로 비교하면 충분한가요?
A dictionary gives names and units but no aggregation window. Is matching units enough for direct comparison?
풀이와 확인할 이유Solution and explanation
충분하지 않습니다. 하루 합·9개월 합처럼 기간이 다를 수 있습니다. 관측 대상, 집계 기간, 측정 방식과 가용 분모까지 확인하고 모르는 것은 명시합니다.
No. Daily and nine-month totals can share units. Check observational scope, window, measurement and denominators, retaining unknowns explicitly.
15. 와인 점수의 간격Distances between wine scores
quality가 순서형 점수입니다. 점수 4→5와 7→8이 모든 소비자에게 같은 만족 증가라고 결론낼 수 있나요?
Quality is an ordered score. Must changes 4→5 and 7→8 give every consumer equal satisfaction gains?
풀이와 확인할 이유Solution and explanation
그렇지 않습니다. 순서는 간격의 동일성이나 소비자 간 비교를 보장하지 않습니다. 평균·회귀에 수치 간격을 사용한다면 분석 선택과 해석 한계를 밝힙니다.
No. Ordering does not establish equal gaps or interpersonal satisfaction comparisons. State numerical-gap assumptions when using means or regression.
16. 미확인 화학 단위An unverified chemical unit
원 와인 residual sugar의 첫 값은1.9이고 이 보관 머리글에는 단위가 없습니다. 익숙한 단위를 가정해 바로1000배 환산해도 되나요?
The first residual sugar value is 1.9 and its retained header lacks units. May a familiar unit be assumed and immediately scaled by 1000?
풀이와 확인할 이유Solution and explanation
확인된 원자료 사실처럼 환산하면 안 됩니다. 원 측정 방법에서 단위를 확인하거나 가정 시나리오임을 별도로 밝혀야 합니다. 이번 실제 코드의 conversionPerformed는 false입니다.
Not as a source-verified conversion. Verify the primary method or label a separate assumption. The actual example’s conversionPerformed is false.
17. 두 날짜 해석Two date interpretations
문자열 03/04/2024를 %d/%m/%Y와 %m/%d/%Y로 각각 읽은 결과를 쓰세요.
Interpret 03/04/2024 with %d/%m/%Y and %m/%d/%Y.
풀이와 확인할 이유Solution and explanation
각각2024-04-03과2024-03-04입니다. 둘 다 유효해서 파싱 성공만으로 원뜻을 고르지 못합니다. 원 문자열·선언 형식·출처의 약속을 함께 보관합니다.
They yield 2024-04-03 and 2024-03-04. Both are valid, so parsing success cannot select the intended source meaning. Preserve text, format and provenance.
18. 윤일의 두 처리Two invalid-leap-day behaviors
2023-02-29에 실제 Python은 ValueError, R as.Date는 NA를 냈습니다. R 종료0이 날짜 유효성을 뜻하나요?
Actual Python gives ValueError and R as.Date gives NA for 2023-02-29. Does R exit 0 establish date validity?
풀이와 확인할 이유Solution and explanation
아닙니다. 프로세스 성공과 값의 유효성이 다릅니다. R의 변환 뒤 NA를 확인하고 원래 미관측과 변환 실패를 구별합니다. Python 오류 이름을 R에 지어 붙이지 않습니다.
No. Process success and value validity differ. Inspect the returned NA and distinguish source missingness from conversion failure without inventing Python exceptions for R.
19. 2분기의 경계Quarter-two boundaries
2024-Q2의 시작 월·마지막 월과 달력 시작·끝 날짜를 계산하세요. 끝 날짜는 측정일로 관측한 사실인가요?
Find first/last months and dates of 2024-Q2. Is the last date an observed measurement timestamp?
풀이와 확인할 이유Solution and explanation
시작 월은3×2−2=4, 마지막 월은6입니다. 경계는2024-04-01과2024-06-30입니다. 기간 표지에서 계산한 경계이며 실제 측정 시각을 새로 관측한 것은 아닙니다.
Months are 4 and 6; boundaries are 2024-04-01 and 2024-06-30. They are derived from the period label, not newly observed measurement times.
20. 4분기의 다음 분기The quarter after quarter four
2024-Q4의 다음 분기 첫날과 현재 분기 마지막 날을 구하세요. 단순히 월에3을 더하면 무엇을 주의하나요?
Find the next-quarter start and current-quarter end for 2024-Q4. What is missing from simply adding three to the month?
풀이와 확인할 이유Solution and explanation
다음 첫날은2025-01-01, 현재 마지막 날은2024-12-31입니다. 월이12를 넘으면 연도도 넘겨야 합니다. 원 기간 표지를 보존하고 파생 날짜를 별도 열에 둡니다.
The next start is 2025-01-01 and current end 2024-12-31. Advance the year when months pass twelve, retaining source period labels separately from derived dates.
21. 45년의 분기 수Counting quarters over 45 years
1980-Q1부터 2024-Q4까지 모든 분기가 하나씩 있습니다. 연도 수와 기록 수를 구하세요. 180개의 분기가 180개의 독립 추첨이라는 뜻인가요?
There is one record for every quarter from 1980-Q1 through 2024-Q4. Count years and records. Does this establish 180 independent draws?
풀이와 확인할 이유Solution and explanation
양 끝 연도를 포함해 2024−1980+1=45년, 따라서 45×4=180개입니다. 이는 기간 수를 세는 계산입니다. 시간 의존이 있을 수 있으므로 독립 표집이나 임의 추첨을 인증하지 않습니다.
Including both years gives 45 years and 180 quarters. This counts periods; it does not establish independent random sampling or absence of temporal dependence.
22. 윤년과 분기 길이Leap years and quarter lengths
그레고리력 2024-Q1은 1월 31일·2월 29일·3월 31일입니다. Q1 일수와 4~6월인 Q2 일수를 구하세요. 모든 분기를 같은 90일로 바꾸면 무엇이 사라지나요?
In the Gregorian calendar, 2024-Q1 has months of 31, 29 and 31 days. Find its length and that of April–June. What is lost by replacing every quarter with 90 days?
풀이와 확인할 이유Solution and explanation
Q1은 31+29+31=91일, Q2도 30+31+30=91일입니다. 다른 분기는 길이가 다를 수 있고 윤년도 달라집니다. 분기 지수의 원 정의가 이미 어떤 집계를 쓰는지 확인해야 하며, 달력 길이만으로 원 지수를 일별 관측으로 복원할 수는 없습니다.
Both quarters have 91 days. Other quarters and years need not have that length. Inspect the indicator’s aggregation rule; calendar lengths cannot reconstruct unobserved daily index values.
23. 상대 월의 달력 연도Relative months without a calendar year
고객 설명에는 첫 9개월의 입력 요약과 12개월 시점의 이탈이 있지만 달력 시작 연도가 없습니다. 원행 1의 달력 측정일을 만들 수 있나요?
Customer metadata describes inputs over the first nine months and churn at month twelve, but gives no calendar start year. Can a calendar measurement date be assigned to source row one?
풀이와 확인할 이유Solution and explanation
만들 수 없습니다. 상대 창은 비교 순서를 알려 주지만 달력 원점은 주어지지 않았습니다. 원행 번호를 월이나 고객의 영구 ID로 바꾸지 않고, 상대 창과 미확인 달력 연도를 기록합니다.
No. Relative windows specify an ordering, not an unprovided calendar origin. A row number is neither a month nor a permanent customer identifier. Preserve the relative window and unknown calendar year.
24. 앞 24개 분기의 범위Coverage of the first 24 quarters
BIS의 첫 24개 분기는 1980-Q1부터 연속이며 토지 가격 대용 범위입니다. 마지막 해당 분기와 다음 분기를 구하고 주택 범위 전환을 표시하세요.
The first 24 BIS quarters begin at 1980-Q1 and use the land-price proxy coverage. Find the last such quarter and the next quarter.
풀이와 확인할 이유Solution and explanation
24/4=6년이므로 마지막은 1985-Q4, 다음은 1986-Q1입니다. 전환 전후 범위를 메타데이터로 보존합니다. 같은 지수 열이라는 이유로 모든 기간이 완전히 같은 대상이라고 단정하지 않습니다.
Twenty-four quarters cover six years, ending at 1985-Q4. The next is 1986-Q1. Retain the coverage transition rather than treating an unchanged column name as evidence of identical measurement scope.
25. 초를 분으로 바꾼 평균A mean after seconds-to-minutes conversion
가정 관측은 0초·60초·120초·미관측입니다. 미관측만 제외해 초 단위 평균과 분 단위 평균을 구하세요.
Toy observations are zero, sixty, one hundred twenty seconds and one missing value. Find means in seconds and minutes, excluding only missingness.
풀이와 확인할 이유Solution and explanation
가용 분모는 3입니다. 초 평균은 (0+60+120)/3=60초, 분 값은 0,1,2라 평균 1분입니다. 0초도 유효한 관측이며 미관측을 0으로 채워 4로 나누지 않습니다.
Three values are available. Their mean is 60 seconds, or one minute after dividing every value by 60. Retain zero; do not replace missingness by zero and divide by four.
26. 환산 후 기술분산Descriptive variance after conversion
같은 가정 유효값 (0,60,120)초에 n분모 기술분산을 사용합니다. 초 제곱과 분 제곱의 분산을 계산하세요.
Use n-divisor descriptive variance for the toy available values (0,60,120) seconds. Calculate variance in squared seconds and squared minutes.
For n≥1 fixed available values, let yᵢ=cxᵢ with constant c. Derive the mean and n-divisor variance identities.
풀이와 확인할 이유Solution and explanation
합의 선형성을 사용하면 평균이 c배입니다. 각 중심 편차도 c배이므로 제곱합은 c²배입니다.
yˉ=cxˉyi−yˉ=c(xi−xˉ)vy=c2vx
이는 같은 가용 행에 같은 변환을 적용한 항등식입니다. 선택 행이나 결측 규칙을 바꾸면 다른 계산이 됩니다.
Linearity gives the first identity; scaling centered deviations gives the second.
yˉ=cxˉvy=c2vx
The identities apply to the same available rows under the same transformation. Changing selection or missingness rules changes the comparison.
28. 아핀 변환의 차이와 비율Differences and ratios under an affine map
가정 온도 변환은 F=1.8C+32입니다. C=0,10의 변환값과 차이를 구하세요. 온도 수준 비율이 보존되나요?
A toy temperature map is F=1.8C+32. Transform zero and ten, find the difference, and determine whether level ratios are preserved.
풀이와 확인할 이유Solution and explanation
변환값은 32와 50이고 차이는 18입니다. 차이는 1.8배지만 수준 비율은 원점 이동 때문에 보존되지 않습니다. 원 C의 10/0도 미정의입니다. 이 가정 수치 예는 실제 온도를 새로 측정한 기록이 아닙니다.
The values are 32 and 50, differing by 18. Differences scale by 1.8; level ratios need not survive an origin shift. The original ratio 10/0 is undefined. These are assumed values, not new temperature measurements.
29. 기준값 80을 100으로Rebasing eighty to one hundred
가정 지수 값 (80,100,120)을 첫 값 80=100으로 다시 표시합니다. 환산값과 보존되는 비율을 구하세요.
Rebase toy index values (80,100,120) so the first value eighty becomes one hundred. Find transformed values and a preserved ratio.
풀이와 확인할 이유Solution and explanation
각 값에 100/80=1.25를 곱하므로 (100,125,150)입니다. 첫 값 대비 마지막 값의 비율은 120/80=150/100=1.5로 같습니다. 이 단순 재기준은 물가 자료를 사용한 명목→실질 조정이 아닙니다.
Multiplying by 100/80 gives (100,125,150). The last-to-first ratio remains 1.5. This rescaling does not perform a nominal-to-real adjustment using price data.
30. 공표 평균과 기준 정의A reported average and a reference definition
실제 보관 2010년 네 지수 소수값의 평균은 4000113/40000입니다. 100과의 차이를 구하고 기준 정의가 틀렸다고 즉시 결론낼 수 있는지 설명하세요.
Four retained 2010 decimals average 4000113/40000. Find the difference from one hundred. Does that alone disprove the reference definition?
풀이와 확인할 이유Solution and explanation
평균은 100.002825이고 100과 차이는 113/40000=0.002825입니다. 보관한 공표 소수값의 산술평균과 원 지수의 기준 설정은 구별합니다. 표시 반올림·원 지표 작성 정의를 확인하며 차이만으로 모든 원 계산이 잘못됐다고 결론내리지 않습니다.
The average is 100.002825, differing by 0.002825. Distinguish arithmetic on retained reported decimals from the source construction reference. Inspect rounding and methodology instead of treating the discrepancy alone as proof of a construction error.
31. 범위를 모르는 합Adding incompatible quantities
한 열은 초 단위 9개월 사용시간이고 다른 열은 개월 단위 구독 길이입니다. 두 수를 더해 총 사용량이라고 해도 되나요?
One field measures use in seconds over nine months; another measures subscription length in months. Is their sum total usage?
풀이와 확인할 이유Solution and explanation
측정 차원이 다르고 집계 창도 다르므로 단순 합의 의미가 정해지지 않습니다. 초와 분처럼 같은 차원의 명시적 환산과는 다릅니다. 질문에 맞는 변수·단위·기간 정의를 먼저 정합니다.
No meaningful total follows from adding incompatible dimensions and windows. This differs from an explicit conversion within one dimension. Define the target, units and periods first.
32. 문자 수와 바이트 수Characters and bytes
같은 사전 텍스트의 UTF-8 사본은 73바이트, CP949 사본은 63바이트입니다. 한글 10음절이 각각 3바이트와 2바이트로 표현되고 나머지 바이트는 같습니다. 차이를 설명하세요.
A dictionary has 73 UTF-8 bytes and 63 CP949 bytes. Ten Hangul syllables use three versus two bytes each; all other bytes match in length. Explain the difference.
풀이와 확인할 이유Solution and explanation
한글 부분 차이는 10×(3−2)=10바이트로 전체 차이 73−63과 같습니다. 문자 내용은 같아도 인코딩의 바이트 표현은 다를 수 있습니다. 이것을 관측 행이 10개 달라졌다는 뜻으로 읽지 않습니다.
The syllables account for 10×(3−2)=10 extra bytes, exactly the total difference. Equal decoded content can have different byte representations. This does not mean ten observations changed.
33. 엄격 디코딩의 두 오류Two strict-decoding failures
실제 한글 사전에서 다른 인코딩으로 읽은 Python은 UnicodeDecodeError, R은 iconv의 NA 뒤 명시한 guard 오류를 냈습니다. 두 실행을 같은 예외 이름으로 요약해도 되나요?
Wrong-codec Python raises UnicodeDecodeError; R produces iconv NA and then the program’s explicit guard error. May both be reported under one exception name?
풀이와 확인할 이유Solution and explanation
안 됩니다. 각 실제 도구의 결과와 오류 경로를 그대로 기록합니다. R의 guard는 변환 결과 NA를 발견해 실패로 표시한 코드입니다. 모든 플랫폼의 iconv가 모든 잘못된 입력에 같은 동작을 보인다는 일반 증명도 아닙니다.
No. Retain the actual tool and failure path. The R guard detects a missing conversion result. These finite runs also do not prove identical iconv behavior for every platform and malformed byte sequence.
34. BOM의 바이트 증가Three bytes added by a BOM
원 고객 CSV는 131728바이트이고 UTF-8 BOM 3바이트를 앞에 붙인 교육용 사본은 131731바이트입니다. 원자료에도 BOM이 있었다고 말할 수 있나요?
The original customer CSV has 131728 bytes; a teaching copy adds a three-byte UTF-8 BOM and has 131731. Was the BOM present in the source?
풀이와 확인할 이유Solution and explanation
아닙니다. 원 파일은 BOM이 없고 교육용 사본에만 세 바이트를 추가했습니다. 셀 내용이 같아도 파일 바이트와 해시는 달라질 수 있습니다. 원래 상태와 가정 처리를 분리해 기록합니다.
No. Only the teaching copy has the added prefix. Equal parsed cells do not require equal bytes or hashes. Record the source state separately from the teaching transformation.
35. 정상 디코딩과 남은 BOMA successfully decoded BOM
BOM 사본을 plain UTF-8로 읽은 Python이 정상 종료하고 첫 문자 코드점 65279를 보존했습니다. UTF-8 디코딩이 실패한 것인가요?
Plain UTF-8 Python exits successfully and retains initial code point 65279 in the BOM copy. Did UTF-8 decoding fail?
풀이와 확인할 이유Solution and explanation
실패가 아닙니다. U+FEFF가 문자로 남았으며 이후 머리글 정확 비교에 영향을 줄 수 있습니다. utf-8-sig 정책은 선두 BOM을 소비해 첫 코드점이 C의 67이 됩니다. 디코딩 성공과 머리글 의미 처리는 다른 단계입니다.
No. U+FEFF remains a character and may affect exact header lookup. The utf-8-sig policy consumes the leading BOM, yielding initial C with code point 67. Decoding success and header handling are separate stages.
36. R의 두 처리 단계Two stages in R
R의 원 디코딩 텍스트에는 선두 U+FEFF가 남지만 read.table이 만든 첫 머리글은 Call Failure입니다. 이 결과가 모순인가요?
R’s decoded text retains initial U+FEFF, while read.table returns the first header as Call Failure. Is that contradictory?
풀이와 확인할 이유Solution and explanation
모순이 아닙니다. 원 텍스트 디코딩과 표 reader의 머리글 처리가 다른 단계입니다. 이번 reader는 BOM을 별도로 제거했습니다. 따라서 원 텍스트 첫 문자와 파싱된 머리글을 각각 검사하며 두 언어의 동작을 같다고 꾸미지 않습니다.
No. Text decoding and table-header handling are different stages. This reader separately removes the prefix. Inspect decoded text and parsed headers independently rather than making the two languages appear identical.
37. 손실적 디코딩Lossy decoding
디코더가 읽지 못한 바이트를 모두 대체 문자 하나로 바꾸어 성공 문자열을 만들었습니다. 원바이트를 항상 복구할 수 있나요?
A decoder replaces every unreadable byte pattern with the same replacement character. Is exact byte recovery always possible?
풀이와 확인할 이유Solution and explanation
항상 복구하지 못합니다. 서로 다른 오류 바이트가 같은 대체 문자열로 갈 수 있기 때문입니다. 원바이트와 오류 위치를 보존하며 성공 문자열만 보고 원 측정이나 인코딩을 인증하지 않습니다.
No. Distinct byte inputs may produce the same replacement text. Preserve original bytes and failure locations; an output string alone does not certify the original encoding or measurement.
38. 해시와 한글 의미Hashes and Korean text
UTF-8과 CP949 사전의 바이트 해시가 다르지만 올바른 디코딩 뒤 한글 텍스트가 같습니다. 무엇을 각각 비교한 것인가요?
UTF-8 and CP949 dictionaries have different byte hashes but equal correctly decoded Korean text. What do the two comparisons establish?
풀이와 확인할 이유Solution and explanation
해시는 바이트 표현을 비교하고, 디코딩 뒤 비교는 선택한 인코딩 아래의 문자 내용을 비교합니다. 바이트 다름·문자 같음은 함께 가능하며, 문자 같음도 자료사전의 사실 정확성까지 증명하지는 않습니다.
They compare byte representations and decoded character content respectively. Different bytes can encode equal text. Text equality still does not establish the dictionary’s substantive accuracy.
39. 실행 기록의 범위Scope of archived runs
44개의 고정 실제 Python/R 실행이 이번 입력에서 모두 예상한 성공·오류를 냈습니다. 브라우저가 임의 Python/R 프로그램을 실행한다고 소개해도 되나요?
Forty-four fixed actual Python/R processes produce expected successes and failures for retained inputs. Does the browser therefore execute arbitrary language programs?
풀이와 확인할 이유Solution and explanation
안 됩니다. 브라우저는 보관 기록을 선택해 보여 주는 제한된 조회기입니다. 다운로드 코드와 실제 프로세스 실행은 별도 경로입니다. 기록은 입력·코드·버전·옵션과 함께 보관하고 모든 미래 입력을 검증했다고 말하지 않습니다.
No. It selects archived records. Downloaded code runs through a separate real-process route. Preserve inputs, code, versions and options, and do not extend finite checks into certification of every future input.
40. 와인 빈도 합Wine score frequencies
실제 레드 quality 3~8의 빈도는 10,53,681,638,199,18입니다. 합과 점수 5의 경험 상대빈도를 구하세요.
Actual red quality scores three through eight have counts 10,53,681,638,199,18. Find the total and empirical relative frequency of score five.
풀이와 확인할 이유Solution and explanation
합은 1599이고 점수 5의 빈도는 681입니다. 따라서 681/1599=227/533≈0.425891입니다. 이 파일의 경험 법칙이며 모든 와인 생산자나 미래 제품에 대한 모집단 확률로 자동 확장하지 않습니다.
They sum to 1599. Score five has mass 681/1599=227/533≈0.425891 in this empirical law. That is not automatically a population or future-product probability.
41. 고객 코드를 찾는 법Looking up customer codes
실제 고객 첫 원행의 call_failure는 8, charge_amount는 0입니다. 분석 이름만 보고 둘 다 횟수나 둘 다 금액이라고 판단할 수 있나요?
The first actual row has call_failure eight and charge_amount zero. Can analysis names alone establish that both are counts or both monetary amounts?
풀이와 확인할 이유Solution and explanation
안 됩니다. 원 이름과 사전으로 각각 통화 실패 횟수와 요금 수준 코드를 확인합니다. 분석 이름에 amount가 있어도 실제 통화 단위 금액이라는 증거가 되지 않습니다. 0도 선언한 코드의 유효값입니다.
No. The dictionary distinguishes a failure count from a charge-level code. The word amount in an analysis name does not establish a monetary unit; zero remains a valid declared code.
42. 품질 점수의 범위Possible and observed score ranges
관측 quality는 3~8인데 자료 설명의 가능한 척도는 더 넓습니다. 0~10이라는 가능 척도로부터 빠진 점수의 관측 행을 새로 만들어야 하나요?
Observed quality is three through eight, while the possible scale is zero through ten. Must rows for the unobserved scores be added?
풀이와 확인할 이유Solution and explanation
아닙니다. 가능 범위와 실제 관측 지지집합을 구별합니다. 빈도표에 미관측 점수의 빈도 0을 표시할 수는 있지만 원 관측 행을 가상으로 추가하지 않습니다.
No. Distinguish the scale’s possible range from observed support. A frequency table can show zero counts without adding fictitious observation rows.
43. 원행 키와 영구 IDSource-row keys and persistent IDs
고객 3150행과 와인 1599행에 source_row_id를 붙였습니다. 이 번호가 고객의 영구 ID나 와인 병 식별자인가요?
Source-row numbers are added to 3150 customer and 1599 wine records. Are they permanent customer or bottle identifiers?
풀이와 확인할 이유Solution and explanation
아닙니다. 현재 보관 순서의 원행을 추적하는 출처 키입니다. 정렬이나 결합 시 값을 함께 보존할 수 있지만 원자료에 없는 개체 신원을 발견한 것은 아닙니다.
No. They trace records in this archived order. Retain them through sorting and joins without claiming newly identified individuals or bottles.
44. 넓이와 단위의 배수Density heights under a scale change
가정 변수 y=1000x에서 밀도 모형이 있다면 밀도 높이는 f_y(y)=f_x(y/1000)/1000입니다. 단순히 높이를 1000배 해야 한다는 주장과 무엇이 다른가요?
In an assumed density model, y=1000x implies f_y(y)=f_x(y/1000)/1000. Explain why multiplying height by one thousand is wrong.
풀이와 확인할 이유Solution and explanation
구간 폭이 1000배가 되므로 확률을 보존하려면 높이는 1/1000배입니다.
dy=1000dxfy(y)dy=fx(x)dx
이는 명시한 연속 밀도 모형의 변수변환입니다. 이번 실제 원자 자료가 자동으로 연속 밀도를 가진다는 주장은 아닙니다.
Widths grow by one thousand, so heights shrink to preserve probability.
dy=1000dxfy(y)dy=fx(x)dx
This is a transformation of a declared continuous density model; it does not make the actual discrete records continuously distributed.
45. 환산과 검정 통계량A statistic after unit conversion
같은 n≥2개 가용값의 t 통계량 t=(x̄−μ₀)/(s/√n)에서 모든 값과 μ₀를 양수 c배 합니다. s>0일 때 t가 변하나요?
For n≥2 available values with s>0, let t=(x̄−μ₀)/(s/√n). Multiply every value and the reference by c>0. Does t change?
풀이와 확인할 이유Solution and explanation
표본 표준편차도 c배이므로 분자·분모가 같은 배수로 바뀌어 통계량이 같습니다.
yˉ−ν0=c(xˉ−μ0)sy=csxty=tx
이는 산술 항등식입니다. iid 정규 같은 추론 조건을 새로 인증하지 않으며 원단위 효과와 통계량도 구별합니다.
Both numerator and denominator scale by c.
sy=csxty=tx
This algebraic identity does not certify inferential assumptions such as iid normal sampling. The effect in original units still changes numerically.
46. 0배 변환의 역함수An inverse for zero scaling
가정 y=cx에서 c=0입니다. 원값을 모두 복구할 수 있나요? c≠0일 때와 비교하세요.
For y=cx with c=0, can all original values be recovered? Compare with nonzero c.
풀이와 확인할 이유Solution and explanation
c=0이면 모든 x가 0으로 가므로 원값을 복구할 수 없습니다. c≠0이면 정확 산술에서 x=y/c로 역변환합니다. 실제 저장 반올림이 추가되면 역변환 가능성은 그 저장 규칙까지 검토해야 합니다.
Zero scaling maps all inputs to zero and is not invertible. For nonzero c, exact arithmetic permits x=y/c. Additional storage rounding requires a separate reversibility check.
47. 결측과 빈 문자열의 내보내기Exporting missingness and empty text
가정 내보내기 함수가 미관측과 실제 빈 문자열을 둘 다 같은 빈 CSV 필드로 씁니다. 결과 파일만으로 어느 쪽이었는지 항상 판단할 수 있나요?
A toy exporter writes both missingness and a genuine empty string as the same empty CSV field. Can the output alone always identify the original state?
풀이와 확인할 이유Solution and explanation
항상 판단할 수 없습니다. 서로 다른 두 입력이 같은 출력이 되는 비일대일 변환입니다. 구별이 필요하면 별도 결측 표지·스키마·원문을 보존하고 왕복 검사에서 그 차이를 확인합니다.
No. Two distinct inputs share an output. Preserve a separate missing indicator, schema or original text when the distinction matters, and test it in round trips.
48. 읽기 계약의 합성Composing the import stages
바이트→문자 디코딩 D와 문자→표 파싱 P를 합쳐 T=P∘D라 합니다. P가 입력 두 문자열을 같은 표로 보내면 D가 정확해도 T는 항상 가역인가요?
Let D decode bytes to text and P parse text to tables, with T=P∘D. If P merges two strings, is T necessarily invertible whenever D is correct?
풀이와 확인할 이유Solution and explanation
아닙니다. D의 범위 안에 서로 다른 s₁,s₂가 있고 P(s₁)=P(s₂)라면 그에 대응하는 서로 다른 바이트가 같은 표로 갈 수 있습니다.
D(b1)=s1,D(b2)=s2P(s1)=P(s2)T(b1)=T(b2)
원바이트 보존과 파싱된 셀 비교의 역할을 나누는 이유입니다. 정보 손실이 D의 실제 범위 밖에서만 일어나면 이 반례를 바로 적용하지 못하므로 범위 조건도 필요합니다.
No. If distinct strings s₁, s₂ in the range of D satisfy P(s₁)=P(s₂), their distinct byte preimages can yield the same table.
T(b1)=P(s1)T(b2)=P(s2)T(b1)=T(b2)
The range condition matters: merging strings outside D’s actual range alone does not prove a collision for T. Preserve original bytes separately from parsed-cell comparisons.
49. 이름 바꾸기의 필요 조건A condition for reversible renaming
유한 원 열 집합 H에서 분석 이름 함수 r을 사용해 원 열을 고유하게 찾으려 합니다. 역대응을 유일하게 만들기 위한 조건과 반례를 쓰세요.
A renaming map r sends a finite set of source headers H to analysis names. What is required for unique reverse lookup? Give a counterexample.
풀이와 확인할 이유Solution and explanation
r이 H에서 일대일이어야 합니다. r(A B)=r(AB)=AB처럼 충돌하면 분석 이름만으로 어느 원 열인지 알 수 없습니다. 일대일 대응표를 보존해도 단위·측정 의미가 정확하다는 별도 사실까지 증명되는 것은 아닙니다.
The map must be injective on H. Removing spaces from A B and AB maps both to AB, preventing unique reverse lookup. Even an injective retained map does not establish substantive measurement accuracy.
50. 반올림 왕복의 실패A failed rounding round trip
가정 소수 1.234와 1.235를 소수 둘째 자리까지만 내보냅니다. 반올림 방법을 선언하더라도 그 출력만으로 모든 원 소수를 복구할 수 있나요?
Toy decimals 1.234 and 1.235 are exported with only two decimal places. Does declaring a tie rule make all original decimals recoverable?
풀이와 확인할 이유Solution and explanation
불가능합니다. 유한 자릿수 표시는 여러 서로 다른 소수를 같은 결과로 합칠 수 있습니다. 특정 두 값의 결과는 동률 처리 규칙에 따라 달라질 수 있지만 일반적인 정보 손실은 남습니다. 원 소수 문자열과 출력 정책을 따로 보관합니다.
No. Fixed-precision rounding can merge distinct values. The displayed result for a particular halfway case depends on its tie rule, but the general information loss remains. Retain source decimal strings and the output policy separately.
51. 시간대가 없는 문자열A timestamp without a zone
가정 시각 문자열은 2024-01-01 09:00이고 시간대가 없습니다. 서울의 UTC 시각을 확정할 수 있나요?
A toy timestamp is 2024-01-01 09:00 without a time zone. Can its UTC time in Seoul be established?
풀이와 확인할 이유Solution and explanation
확정할 수 없습니다. 먼저 그 문자열이 서울 현지 시각이라는 출처 약속이 필요합니다. 그런 약속을 별도로 주면 UTC+9인 해당 시점의 변환을 계산할 수 있지만 원 문자열만으로 지역을 발명하지 않습니다. 이 장의 실제 날짜 기록은 새 시간대 실행 실험이 아닙니다.
Not from the text alone. A separate source contract must identify it as Seoul local time before applying that date’s UTC+9 offset. Do not invent a location. The archived date examples do not constitute new time-zone execution experiments.
52. 원파일과 스키마A source file and its schema
실제 3150×14 파일이 모든 선언한 코드 범위를 통과했습니다. 고객의 원 응답이 진실이고 모집단을 대표한다고 결론낼 수 있나요?
All values in an actual 3150-by-14 file satisfy declared code ranges. Does that establish truthful responses and population representativeness?
풀이와 확인할 이유Solution and explanation
아닙니다. 스키마 검사는 읽은 값이 선언한 형태·범위와 맞는지 확인합니다. 측정 오류·표집 과정·대표성·행 간 의존은 별도 근거가 필요합니다. 통과한 검사 범위를 정확히 보고합니다.
No. Schema checks concern conformity to declared shapes and domains. Measurement accuracy, sampling, representativeness and dependence need separate evidence. Report the scope that was actually checked.
53. 제한된 XML 검사A limited XML inspection
R 예제가 보관 BIS 파일의 Obs 태그를 정규식으로 확인했습니다. 모든 SDMX XML을 올바로 읽는 일반 XML 파서라고 설명해도 되나요?
An R example inspects Obs tags in the retained BIS serialization using a regular expression. Is it a general SDMX XML parser?
풀이와 확인할 이유Solution and explanation
안 됩니다. 이 보관 직렬화의 관측 태그를 확인하는 제한된 검사입니다. 일반 XML의 네임스페이스·이스케이프·다양한 문법을 처리한다는 증명이 아니며, 확장하려면 적절한 파서와 검사가 필요합니다.
No. Its scope is the observed tags in this retained serialization. It does not certify general handling of namespaces, escaping or other XML forms. Broader support requires an appropriate parser and checks.
54. 비교할 네 층Four comparison layers
바이트 같음·디코딩 문자 같음·파싱 셀 같음·관측 의미 같음 네 검사를 모두 같은 검증으로 요약하면 무엇을 놓치나요?
What is lost by describing equal bytes, decoded text, parsed cells and observational meaning as one identical check?
풀이와 확인할 이유Solution and explanation
층마다 다른 동등성을 검사합니다. 인코딩이 다르면 문자는 같아도 바이트는 다를 수 있고, 다른 인용 표기도 같은 셀을 만들 수 있습니다. 같은 숫자 셀이라도 단위·창·대상이 다를 수 있으므로 자료사전을 함께 확인합니다.
They test different equivalences. Different encodings can yield equal text; different quoting can yield equal cells. Equal numbers can still refer to different units, windows or entities, requiring metadata.
55. 정직한 읽기 보고서An honest import report
원 고객 CSV를 읽은 결과를 동료에게 전달합니다. 최소한 파일·환경·읽기 규칙·결과·모르는 정보에서 무엇을 적겠나요?
You hand an actual customer import to a colleague. What should be recorded about file, environment, rules, result and unknowns?
풀이와 확인할 이유Solution and explanation
입력 출처와 해시, 실제 언어 버전·관련 인코딩/출력 옵션, 구분자·인용·머리글·결측·자료형 규칙, 3150행·14열·원 이름 대응과 검사 결과를 적습니다. 0의 코드 의미·상대 시간 창·달력 연도 미확인도 함께 씁니다. 실제 실행과 브라우저의 고정 기록 조회를 구별합니다.
Include source and hash, language version and relevant encoding/output options, delimiter, quoting, header, missing/type rules, 3150 rows and fourteen fields, source-name mapping and checks. Retain valid-zero code meanings, relative windows and the unknown calendar year. Separate real execution from browser record selection.
56. 사전의 숫자 코드와 산술Numerical labels and arithmetic
가정 요금제 코드는 1과 2이고 두 기록에 하나씩 있습니다. 코드를 10과 20으로 다시 붙이면 평균이 1.5에서 15로 바뀝니다. 요금제 구성 비율도 바뀌나요?
Two toy tariff categories have one record each and codes one and two. Relabeling them ten and twenty changes the mean code from 1.5 to 15. Did category shares change?
풀이와 확인할 이유Solution and explanation
각 범주는 여전히 1/2이므로 구성은 같습니다. 바뀐 것은 임의 숫자 이름의 산술평균입니다. 수치 코드를 양적 크기로 해석하려면 별도 측정 의미가 필요합니다.
No. Each share remains one half. Only arithmetic on arbitrary numerical labels changed. Quantitative interpretation requires additional measurement meaning.
57. 다시 쓴 CSV의 바이트Bytes after rewriting CSV
가정 두 CSV는 하나는 모든 필드에 따옴표를 붙이고 다른 하나는 필요한 필드에만 붙였지만 같은 계약으로 같은 셀을 읽습니다. 출력 해시가 같아야 하나요?
Two toy CSVs quote all fields or only fields requiring quotes, but parse to equal cells under one contract. Must their byte hashes agree?
풀이와 확인할 이유Solution and explanation
그럴 필요가 없습니다. 같은 파싱 결과를 여러 바이트 표현으로 저장할 수 있습니다. 셀 왕복 검사는 셀 동등성을, 원바이트 해시는 바이트 보존을 검사하므로 목표를 따로 선언합니다.
No. Multiple byte representations can produce the same cells. A cell round-trip check and a byte-preservation check address different targets.
58. 소수 문자열의 보존Preserving decimal text
원 문자열은 0.10과 0.100입니다. 정확한 수로는 같지만 원 표기까지 보존하려면 무엇이 필요한가요?
Source strings are 0.10 and 0.100. They denote equal exact numbers. What is needed to preserve the original notation too?
풀이와 확인할 이유Solution and explanation
숫자값과 원 문자열을 구별해 보관합니다. 정확 수치 동등성은 1/10=1/10이지만 자릿수 표기·출력 양식은 다릅니다. 단순 표기만으로 측정 오차 크기를 확정하지도 않습니다.
Retain original strings separately from numerical values. Both denote one tenth, but their written precision differs. Written digits alone do not establish measurement uncertainty.
59. 가중 평균의 단위 변환Unit conversion of a weighted mean
같은 n≥1개 값에 비음수 고정 가중치 wᵢ를 쓰며 W=Σwᵢ>0입니다. yᵢ=cxᵢ로 바꿀 때 가중 평균도 c배인지 보이세요.
For n≥1 values, fixed nonnegative weights satisfy W=Σwᵢ>0. Show how the weighted mean changes under yᵢ=cxᵢ.
풀이와 확인할 이유Solution and explanation
가중치와 선택 행을 그대로 두면 분자의 모든 항만 c배가 됩니다.
xˉw=W∑iwixiyˉw=Wc∑iwixiyˉw=cxˉw
가중치를 새로 정하거나 관측을 제외하면 이 같은 법칙 비교가 아닙니다. 단위 환산만으로 국가 균등과 인구 가중 표적이 같아지지는 않습니다.
Keeping the same weights and rows gives:
yˉw=W∑iwicxiyˉw=cxˉw
Changing weights or selection changes the target. Unit conversion alone does not equate country-uniform and population-weighted means.
60. 변환 순서가 중요한 예An example where operation order matters
가정 양수 값 2와 4의 평균에 역수를 취한 값과, 각 역수의 평균을 계산하세요. 둘이 다르면 왜 읽기 보고서에 변환 순서도 필요한가요?
For toy positive values two and four, compare the reciprocal of the mean with the mean of reciprocals. Why should an import/reporting contract retain transformation order?
풀이와 확인할 이유Solution and explanation
평균의 역수는 1/3이고 역수의 평균은 (1/2+1/4)/2=3/8입니다. 비선형 변환은 일반적으로 평균과 교환되지 않습니다. 원값을 먼저 변환했는지 요약 뒤 변환했는지 기록해야 하며, 이 가정 예를 원자료에서 새로 관측한 값처럼 쓰지 않습니다.
The reciprocal of the mean is one third; the mean reciprocal is three eighths. A nonlinear transformation need not commute with averaging. Declare whether transformation preceded or followed aggregation; these toy calculations are not new source observations.
자료별 확보일·원행 식별·단위·이용 조건은 출처 기록을 확인하세요. 학습 사본은 제공처의 현재 최신 자료와 다를 수 있습니다.Consult each source record for retrieval dates, row identifiers, units and terms. Teaching copies can differ from current provider releases.