본문 바로가기
Kaggle Learn

Data Visualization - Line Charts

by 가으더 2024. 3. 21.
728x90

https://www.kaggle.com/code/alexisbcook/line-charts

 

Line Charts

Explore and run machine learning code with Kaggle Notebooks | Using data from Interesting Data to Visualize

www.kaggle.com

Plot the data

각 곡의 하루 글로벌 스트리밍을 보며주는 line chart

# Line chart showing daily global streams of each song 
sns.lineplot(data=spotify_data)

 

- sns.lineplot : line chart 생성

- data - spotify_data : 차트 생성에 사용되는 데이터를 선택한다.

 

추가적인 디테일(사이즈, 제목) 수정 방법

# Set the width and height of the figure
plt.figure(figsize=(14,6))

# Add title
plt.title("Daily Global Streams of Popular Songs in 2017-2018")

첫번째 코드 : 14인치(가로), 6인치(세로) 사이즈 설정

Plot a subset of the data

열의 부분 집합을 표현하는 방법에 대해 설명한다.

 

colums 확인 방법 : list()

list(spotify_data.columns)
['Shape of You',
 'Despacito',
 'Something Just Like This',
 'HUMBLE.',
 'Unforgettable']

 

# Line chart showing daily global streams of 'Shape of You'
sns.lineplot(data=spotify_data['Shape of You'], label="Shape of You")