파일 가져오기 성능
여러분은 큰 데이터셋을 Spark DataFrame으로 가져오라는 요청을 받았어요. 파일을 분할해서 가져올 때와의 속도 차이를 테스트해 보려고 합니다.
사용할 수 있는 파일은 두 종류예요. 하나는 departures_full.txt.gz, 다른 하나는 departures_xxx.txt.gz이고 여기서 xxx는 000 - 013입니다. 각 파일에는 동일한 수의 행이 균등하게 나뉘어 있습니다.
이 연습은 강의의 일부입니다
PySpark로 데이터 정제하기
연습 안내
departures_full.txt.gz파일과departures_xxx.txt.gz파일을 각각 별도의 DataFrame으로 가져오세요.- 각 DataFrame에 대해 count를 실행하고 실행 시간을 비교하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the full and split files into DataFrames
full_df = spark.read.csv('____')
split_df = ____(____)
# Print the count and run time for each DataFrame
start_time_a = time.time()
print("Total rows in full DataFrame:\t%d" % ____)
print("Time to run: %f" % (time.time() - start_time_a))
start_time_b = time.time()
print("Total rows in split DataFrame:\t%d" % ____)
print("Time to run: %f" % (time.time() - start_time_b))