Data Science Fundamentals/Pandas&Numpy and Questions22 🥰 StrataScratch PythonPandas Medium I - 3 Solved 02099 Election Results# Import your librariesimport pandas as pd# Start writing codevoting_results.head() #voter / candidate#boolean indexing - filtering voters who didn't votevoting_results = voting_results[~voting_results['candidate'].isna()] #boolean indexing(condiiton included)#voting_results = voting_results.dropna()#voter ratevoting_results['voter_rate'] = voting_results['voter'].apply(lam.. Data Science Fundamentals/Pandas&Numpy and Questions 2025. 3. 9. map & applymap & apply(for dataframe & Series) 1. apply🔺 pandas.DataFrame.apply 🔻(apply for dataframe)docuDataFrame.apply(func, axis=0, raw=False, result_type=None, args=(), **kwargs) "Apply a function along an axis of the DataFrame. Objects passed to the function are Series objects whose index is either the DataFrame’s index (axis=0) or the DataFrame’s columns (axis=1). By default (result_type=None), the final return type is inferred from.. Data Science Fundamentals/Pandas&Numpy and Questions 2024. 6. 2. dataframe 꾸미기 🤲 pandas의 dataframe을 jupyter css 파일 코드를 고치거나 추가하면 입맛에 맞게 꾸밀 수 있다! 그 과정을 소개해봄 - 수정 후 - 🤲 jupyter notebook styling css 파일 총 2개를 수정했다. ① custom.css ② style.min.css 🤲 custom.css 🤲 설명에 의하면 overriding되는 동일구조 code의 최종 of 최종본을 선언할 때 쓰라는 안내문 🤲 .dataframe은 style.min에서 찾아도 없어서(ctrl+F5 단축키) custom.css에 깔끔히 썼다. .dataframe th{ background:#B7E0F0; font-weight: 600; border:3px solid white; } → tag는 dataframe ta.. Data Science Fundamentals/Pandas&Numpy and Questions 2023. 1. 22. Numpy fundamentals 2/2 🎅 numpy는 필수적으로 알아야 하는 library로, 수학 연산 관련해서 반드시 쓰이는 library. 옛날 포스팅에 이어서 numpy 관련 다양한 기능을 익혀보자! NumPy intro. + fundamentals 1/2 1. 개념 * NumPy = Numerical Python - Python에서 대규모 다차원 배열을 다룰 수 있게 도와주는 library * 데이터의 대부분은 숫자 배열로 볼 수 있기에 NumPy는 꼭 필요 - 이미지나 소리 등 실생활 대부분이 숫 sh-avid-learner.tistory.com 1. numpy 배열 생성 다양한 함수 * 배열 생성 및 초기화 함수 🎅 zeros() - 주어진 형태와 타입을 갖는 0으로 채워진 배열 반환 (지정된 shape 배열을 생성하고 모든 요.. Data Science Fundamentals/Pandas&Numpy and Questions 2023. 1. 16. pandas Tricks (Kevin by DataSchool) 완료! COMPILATION 길고 긴 Keving Pandas Tricks를 모두 끝냈다 😍 (총 14개의 trick 포스팅!) pandas라는 강력한, 극강의 library를 통해 dataframe을 자유자재로 이용할 수 있게 되었다. 추가로 더 알게되는 유용한 기능들이 있다면 계속해서 pandas tricks라는 이름 하에 올릴 예정🙋🏼♂️ https://www.youtube.com/watch?v=RlIiVeig3hc 《pandas tricks compilation》 🏄🏼♂️ 행과 열 순서 바꾸기 pandas Tricks_01 👉🏻 'Reverse (row/column) Order' (Kevin by DataSchool) Q) 데이터프레임이 주어졌다. 근데 내가 원하는 데이터는 행 기준 아래 부분. 데이터 용량이 워낙 커서 .. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 18. pandas Tricks_14👉🏻 'styling a dataframe' (Kevin by DataSchool) 🤳 저번 pandas tricks 시간에는 display 형태를 어떻게 보이게 할 것인지에 대해 배웠었다. 좀 더 flexible한 강력한 dataframe styling에 대해 알아보려 한다! → pandas에는 이미 주어진 dataframe 또는 series를 CSS를 이용하여 cutomized된, 다양한 디자인 + 표시 옵션을 제공해준다. ① dictionary 형태로 format에 원하는 column명과 바뀔 style을 지정한 여러 pair들을 집어넣을 수 있다 ② dataframe 전체에서 적용시키는 여러 method들을 집어넣을 수 있다 (예를 들면 hide_index() 라던가 set_caption(), bar() 등등) pandas Tricks_13👉🏻 'change display opt.. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 18. pandas Tricks_13👉🏻 'change display options' (Kevin by DataSchool) 🕺 pandas & dataframe은 뗄레야 뗄 수 없는 관계! 🕺 ≪주어진 dataframe이 육안상 어떻게 보이게 하는 지 여러 설정을 통해 바꿔보자≫ ※ 여기서 중요한건, data는 internally하게 바뀌지 않는다는 점 (육안상 보이는 형태만 바꿀 뿐!) ※ 🍉 pd.set_option() docu 🍉 https://pandas.pydata.org/pandas-docs/version/0.23/generated/pandas.set_option.html# pandas.set_option(pat, value) = → pat이라는 인자에 바꿀 option의 종류를 집어넣는다 → pat 인자에 맞는 알맞은 value를 설정해 원하는 대로 display되게 설정! ≪pat 종류≫ → 그때 그때 원하는 .. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 17. pandas Tricks_12👉🏻 'pivot_table()' (Kevin by DataSchool) 👆 tidy data 포스팅에서 우리는 tidy한 data를 만들기 위해 기존 dataframe을 melt한다고 하였고, 다시 원위치 시키기 위해 pivot_table()을 활용한다고 배웠다. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 14. pandas Tricks_11👉🏻 'Reshaping → stack() & unstack()' (Kevin by DataSchool) Q. 데이터를 재구조화하는 방법? A. stack() & unstack() 사용! 🙂 ¶ stack() docu https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.stack.html DataFrame.stack(level=- 1, dropna=True) 'Stack the prescribed level(s) from columns to index. Return a reshaped DataFrame or Series having a multi-level index with one or more new inner-most levels compared to the current DataFrame. The new inner-most levels are.. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 14. pandas Tricks_09&10👉🏻 'EXPANDING → a string & a series of lists - into a DF' (Kevin by DataSchool) 😌 dataframe내의 data를 자유자재로 나누어 갖다 붙이고, 들어 있는 게 list면 따로 뽑아내서 갖다 붙이고 싶다면..? → 즉, dataframe 자체를 자유자재로 추가 정보를 붙여 확대하고 싶을 때 사용! ← 1. EXPANDING(1) - splitting a string into MULTIPLE COLUMNS Q) column 내의 string 문자열을 일정 기준으로 나누어 기존 dataframe에 갖다 붙이고 싶으면? A) .column_name.str method를 활용하여 split 적용 → expand = True df = pd.DataFrame({'name': ['Ryan Murphy Kim', 'Jane Doe Rhondall'], 'location': ['Los Angele.. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 14. pandas Tricks_08👉🏻 'missing values - dropna() & isna() (advanced)' (Kevin by DataSchool) * handling missing values는 preprocessing 단계의 일부로 하단 포스팅에서 일부 배웠다 ↓↓↓↓ - dropna, isnull, fillna - Data Preprocessing * concepts🤲 ⊙ Although EDA and Data Preprocessing are two distinct terms, they involve many overlapping subtasks. At times, they are even used interchangeably ⊙ → 즉! 모아진 raw data를 data.. sh-avid-learner.tistory.com Q) NaN 값이 몇%의 값으로 있는 지, NaN이 몇 % 이상 있는 비율 column만 선택해서 제거가 가능한지? A).. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 9. concat & append & merge & join 👋 data는 무수히 여러 종류로 나누어져 있다(for 보안 & 효율성). 합치는 과정을 data preprocessing 과정에서 반드시 겪게 되는 데,, 어떤 case에 어떤 최적의 함수를 사용해야 할 지 이번 포스팅을 통해 총 네 가지! concat, append, merge, join에 대해서 알아보자 👉 docu list - concat) https://pandas.pydata.org/docs/reference/api/pandas.concat.html - append - dataframe) https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.append.html - append - series) https://pandas.pydata.o.. Data Science Fundamentals/Pandas&Numpy and Questions 2022. 4. 9. 이전 1 2 다음