본문 바로가기

티스토리챌린지22

[Linear Regression] Boston Housing Data Data EDA 히스토그램으로 데이터 시각화plt.figure(figsize = (20, 15))plotnumber = 1for column in df: if plotnumber  scatterplot으로 데이터 시각화plt.figure(figsize=(20, 15))plotnumber = 1for column in df: if plotnumber  boxplot으로 데이터 시각화plt.figure(figsize=(20, 8))sns.boxplot(data = df, width=0.8)plt.show()선형회귀분석 전 데이터 처리X, y 선언X = 가격(MEDV) 제외한 모든 컬럼y = 가격X = df.drop(columns = 'MEDV', axis = 1)y = df['MEDV'] 정규화.. 2024. 11. 27.
[시계열분석] polyfit, propher 참고 도서https://m.yes24.com/Goods/Detail/57670268 파이썬으로 데이터 주무르기 - 예스24독특한 예제를 통해 배우는 데이터 분석 입문이 책은 누구나 한 권 이상 가지고 있을 파이썬 기초 문법책과 같은 내용이 아닌, 데이터 분석이라는 특별한 분야에서 초보를 위해 처음부터 끝까지m.yes24.com 라이브러리 호출import pandas as pdimport pandas_datareader.data as webimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsimport warningswarnings.filterwarnings('ignore')from prophet import Prophet from .. 2024. 11. 26.
[row index] Weather Observation Station 20 링크https://www.hackerrank.com/challenges/weather-observation-station-20/problem?isFullScreen=true Weather Observation Station 20 | HackerRankQuery the median of Northern Latitudes in STATION and round to 4 decimal places.www.hackerrank.com 문제A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION.. 2024. 11. 25.
[Selenium] 경기도 주유소 데이터 참고 도서https://m.yes24.com/Goods/Detail/57670268 파이썬으로 데이터 주무르기 - 예스24독특한 예제를 통해 배우는 데이터 분석 입문이 책은 누구나 한 권 이상 가지고 있을 파이썬 기초 문법책과 같은 내용이 아닌, 데이터 분석이라는 특별한 분야에서 초보를 위해 처음부터 끝까지m.yes24.com 라이브러리 호출import pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as pltfrom selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.chrome.service impo.. 2024. 11. 24.
[범주형 인코딩] LabelEncoder, OnehotEncording 함수 정리def get_category(df): from sklearn.preprocessing import LabelEncoder, OneHotEncoder col = ['BLDG_NM'] le = LabelEncoder() oe = OneHotEncoder() for column in col: le.fit(df[column]) new_column = f'{column}_le' df[new_column] = le.transform(df[column]) # index reset df = df.reset_index() for column1 in col: # 원핫인코딩은 array 행렬로 만.. 2024. 11. 23.
[Scaler] StandardScaler, MinMaxScaler 정규화# 정규화def get_numeric_sc(df): from sklearn.preprocessing import StandardScaler, MinMaxScaler col_sdsc = ['column1', 'column2', 'column3'] col_mmsc = ['column1'] sd_sc = StandardScaler() mm_sc = MinMaxScaler() for column in col_sdsc: sd_sc.fit(df[[column]]) new_column = f'{column}_sdsc' df[[new_column]] = sd_sc.transform(df[[column]]) f.. 2024. 11. 22.
[Beautiful Soup] chicago sandwiches 파이썬으로 데이터 주무르기 - 예스24독특한 예제를 통해 배우는 데이터 분석 입문이 책은 누구나 한 권 이상 가지고 있을 파이썬 기초 문법책과 같은 내용이 아닌, 데이터 분석이라는 특별한 분야에서 초보를 위해 처음부터 끝까지m.yes24.com 1. 웹 데이터 가져오는 Beautiful Soup 익히기import pandas as pdimport numpy as npfrom bs4 import BeautifulSouphtml 파일 읽기page = open('~~~.html', 'r').read()soup = BeautifulSoup(page, 'html.parser')print(soup.prettify())- open(): 지정된 경로에 있는 파일을 열어 내용을 읽습니다. - 첫 번째 인자: '파일.. 2024. 11. 21.
[서울시 안전도] 서울시 구별 범죄 발생과 검거율을 지표로 파이썬으로 데이터 주무르기https://github.com/PinkWink/DataScience GitHub - PinkWink/DataScience: 책) 파이썬으로 데이터 주무르기 - 소스코드 및 데이터 공개책) 파이썬으로 데이터 주무르기 - 소스코드 및 데이터 공개. Contribute to PinkWink/DataScience development by creating an account on GitHub.github.comhttps://m.yes24.com/Goods/Detail/57670268 파이썬으로 데이터 주무르기 - 예스24독특한 예제를 통해 배우는 데이터 분석 입문이 책은 누구나 한 권 이상 가지고 있을 파이썬 기초 문법책과 같은 내용이 아닌, 데이터 분석이라는 특별한 분야에서 초보를.. 2024. 11. 20.
[left, right] Weather Observation Station 8 링크https://www.hackerrank.com/challenges/weather-observation-station-8/problem?isFullScreen=true Weather Observation Station 8 | HackerRankQuery CITY names that start AND end with vowels.www.hackerrank.com 문제Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.정답select distinct cityfrom.. 2024. 11. 19.
[Limit/Offset] Second Highest Salary 링크https://leetcode.com/problems/second-highest-salary/description/문제Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null (return None in Pandas).The result format is in the following example.정답select (select distinct Salary from Employee order by salary desc limit 1 offset 1 ) as SecondHighestSala.. 2024. 11. 18.
[boxeplot] Plotting large distributions import seaborn as snssns.set_theme(style="whitegrid")diamonds = sns.load_dataset("diamonds")데이터셋sns.load_dataset("diamonds"): Seaborn에 내장된 다이아몬드 데이터셋을 불러옵니다. 이 데이터셋은 다이아몬드의 가격, 캐럿, 컷 품질, 색상, 투명도(clarity) 등의 정보를 포함하고 있습니다.carat (연속형): 다이아몬드의 무게.clarity (범주형): 다이아몬드의 투명도 등급 (I1, SI2, SI1, VS2, VS1, VVS2, VVS1, IF).cut (범주형): 다이아몬드의 컷 품질.color (범주형): 다이아몬드의 색상 등급.price (연속형): 다이아몬드의 가격.코드 설명clarity.. 2024. 11. 17.
[카이제곱검정] 가설검정 카이제곱 검정# 카이제곱 검정 확인 사항 #1. 범주형 데이터 #2. 관측값은 독립적 #3. 각 셀의 기대빈도(expected frequency)는 5 이상이어야 함 #4. 샘플 크기가 충분해야 함 print('귀무가설:', '''색상과 계절은 독립적이다''')print('대립가설:', '''색상과 계절은 독립적이지 않다\n''')chi_table = pd.crosstab(stat_df['Color'], stat_df['Season'])result = chi2_contingency(chi_table)print("카이제곱 통계량:", result.statistic.round(2))print("p-value:", result.pvalue.round(2))print("자유도:", r.. 2024. 11. 16.
[거래 후기 실험을 통해 따뜻한 거래 경험 만들기]를 읽고 링크https://medium.com/daangn/%EA%B1%B0%EB%9E%98-%ED%9B%84%EA%B8%B0-%EC%8B%A4%ED%97%98%EC%9D%84-%ED%86%B5%ED%95%B4-%EB%94%B0%EB%9C%BB%ED%95%9C-%EA%B1%B0%EB%9E%98-%EA%B2%BD%ED%97%98-%EB%A7%8C%EB%93%A4%EA%B8%B0-3d7ac18d8e3 거래 후기 실험을 통해 따뜻한 거래 경험 만들기거래 후기 실험을 통해 당근마켓이 어떻게 따뜻한 서비스를 만들고 성장시켜 나가는지 소개해 드릴게요!medium.com 요약 좋은 거래 경험은 좋은 거래 후기로 이어진다 당근마켓의 거래 후기: 거래 당사자를 더욱 긴밀하게 연결하기도, 낯선 이웃을 만나게 될 때 그 사람에 대한.. 2024. 11. 15.
[거래 후기 실험을 통해 따뜻한 거래 경험 만들기]를 읽고 링크https://medium.com/daangn/%EA%B1%B0%EB%9E%98-%ED%9B%84%EA%B8%B0-%EC%8B%A4%ED%97%98%EC%9D%84-%ED%86%B5%ED%95%B4-%EB%94%B0%EB%9C%BB%ED%95%9C-%EA%B1%B0%EB%9E%98-%EA%B2%BD%ED%97%98-%EB%A7%8C%EB%93%A4%EA%B8%B0-3d7ac18d8e3 거래 후기 실험을 통해 따뜻한 거래 경험 만들기거래 후기 실험을 통해 당근마켓이 어떻게 따뜻한 서비스를 만들고 성장시켜 나가는지 소개해 드릴게요!medium.com 요약 좋은 거래 경험은 좋은 거래 후기로 이어진다 당근마켓의 거래 후기: 거래 당사자를 더욱 긴밀하게 연결하기도, 낯선 이웃을 만나게 될 때 그 사람에 대한.. 2024. 11. 15.
[upper, lower] Fix Names in a Table 링크https://leetcode.com/problems/fix-names-in-a-table/ 문제Write a solution to fix the names so that only the first character is uppercase and the rest are lowercase.Return the result table ordered by user_id.The result format is in the following example.정답select user_id, concat(upper(substr(name, 1, 1)), lower(substr(name, 2, length(name)))) as namefrom usersorder by user_id해설upper: 문자를 대문자.. 2024. 11. 14.
[Jointgrid] Joint and marginal histograms import seaborn as snssns.set_theme(style="ticks")# Load the planets dataset and initialize the figureplanets = sns.load_dataset("planets")g = sns.JointGrid(data=planets, x="year", y="distance", marginal_ticks=True)planetssns.load_dataset("planets"): Seaborn의 내장 데이터셋 중 하나인 planets 데이터셋을 불러옵니다. 이 데이터셋은 외계 행성(Exoplanet)에 대한 정보를 포함하고 있으며, 각 행성의 발견 연도(year), 지구로부터의 거리(distance), 탐지 방법(method) 등의 변수를 .. 2024. 11. 13.
[row/between] 프레임 정의 'row'와 'between'의 개념ROWS: 물리적인 행 단위로 윈도우 프레임을 정의합니다. 즉, 현재 행을 기준으로 몇 개의 이전 또는 이후 행을 포함할지 결정합니다.BETWEEN: 프레임의 시작과 끝을 명시적으로 지정하는 데 사용됩니다. BETWEEN 절을 사용하면 윈도우 내에서 어느 범위까지 데이터를 포함할지 설정할 수 있습니다.프레임의 경계(Boundaries)UNBOUNDED PRECEDING: 파티션 내에서 첫 번째 행부터 현재 행까지를 포함합니다.CURRENT ROW: 현재 행만 포함합니다.n PRECEDING: 현재 행 이전의 n개의 행을 포함합니다.n FOLLOWING: 현재 행 이후의 n개의 행을 포함합니다.UNBOUNDED FOLLOWING: 현재 행부터 파티션 내 마지막 행까지 포.. 2024. 11. 12.
[WINDOW] Restaurant Growth 링크https://leetcode.com/problems/restaurant-growth/description/문제You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day).Compute the moving average of how much the customer paid in a seven days window (i.e., current day + 6 days before). average_amount should be rounded to two decimal places.Return the result table ordered by visit.. 2024. 11. 11.
[stripplot] Conditional means with observations import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(style="whitegrid") iris = sns.load_dataset("iris") iris 데이터셋 설명 아이리스(Iris) 데이터셋은 세 가지 종류의 붓꽃(setosa, versicolor, virginica)에 대한 네 가지 측정값(꽃받침 길이/너비 및 꽃잎 길이/너비)을 포함하고 있습니다: species: 붓꽃의 종류 (Setosa, Versicolor, Virginica). sepal_length: 꽃받침 길이. sepal_width: 꽃받침 너비. petal_length: 꽃잎 길이. petal_width: 꽃잎 너비. 시각화에서는 이 네 가지 측정값을 하나의 축(m.. 2024. 11. 10.
[displot] Facetting histograms by subsets of data import seaborn as snssns.set_theme(style="darkgrid")df = sns.load_dataset("penguins")df seabornsns.displot( df, x="flipper_length_mm", col="species", row="sex", binwidth=3, height=3, facet_kws=dict(margin_titles=True),)  설명1. sns.displot()displot()은 Seaborn에서 제공하는 분포 시각화 함수로, 히스토그램이나 커널 밀도 추정(KDE) 그래프를 그릴 때 사용됩니다.이 함수는 특히 여러 범주형 변수에 따라 데이터를 나누어 시각화할 때 유용합니다.2. data=dfdf.. 2024. 11. 9.