CSV를 DataFrame으로 불러오기
이전 연습 문제에서 RDD로부터 DataFrame을 만드는 방법을 살펴봤어요. 일반적으로는 CSV 파일에서 데이터를 불러오는 것이 DataFrame을 만드는 가장 흔한 방법입니다. 이번 연습에서는 이미 file_path로 제공된 people.csv 파일에서 PySpark DataFrame을 만들고, 생성된 객체가 PySpark DataFrame인지 확인해 보세요.
워크스페이스에는 이미 SparkSession spark와 people.csv의 경로인 변수 file_path가 준비되어 있어요.
이 연습은 강의의 일부입니다
PySpark로 배우는 빅데이터 기초
연습 안내
people.csv파일 경로인file_path변수에서 DataFrame을 만드세요.- 출력 결과가 PySpark DataFrame인지 확인하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create an DataFrame from file_path
people_df = spark.____(file_path, header=True, inferSchema=True)
# Check the type of people_df
print("The type of people_df is", ____(people_df))