🐍Python

    [Numpy] Numpy 연습문제 31~40

    31. How to ignore all numpy warnings (not recommended)? -> # Suicide mode on defaults = np.seterr(all="ignore") Z = np.ones(1) / 0 # Back to sanity _ = np.seterr(**defaults) An equivalent way, with a context manager: with np.errstate(divide='ignore'): Z = np.ones(1) / 0 해설 : 처음에 all을 ignore로 설정하여 오류발생시 아무 action도 취하지 않게 했다. 그리고 **default로 원래대로 돌려놓는다. 그리고 경고를 표시하지 않으려고 numpy.errstate(divide = ‘ig..

    [Pandas] pandas01 - World Food Facts 풀이

    Step 1. Go to https://www.kaggle.com/openfoodfacts/world-food-facts/data Step 2. Download the dataset to your computer and unzip it. Step 3. Use the tsv file and assign it to a dataframe called food -> import pandas as pd import numpy as np food = pd.read_csv(‘en.openfoodfacts.org.products.tsv', sep='\t’) Step 4. See the first 5 entries -> food.head(5) A : Step 5. What is the number of observati..

    [Numpy] Numpy 연습문제 21~30

    21. Create a checkerboard 8x8 matrix using the tile function -> Z = np.tile(np.array([[0,1],[1,0]]),(4,4)) Z A : array([[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) 해설 : np.array로 0,1 / 1,0을 만들고 가로, 세로4번 반복해준다. 22. Normalize a 5x5 ran..

    [Pandas] Pandas01 - Occupation 풀이

    Step 1. Import the necessary libraries-> import pandas as pdStep 2. Import the dataset from this address.Step 3. Assign it to a variable called users and use the 'user_id' as index-> url ='https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user'data = pd.read_csv(url,'|', index_col='user_id')data.head() A : 해설 : url을 보고 ‘|’로 분리되어 있는 것을 확인. Index_col을 통해 ‘user_id’를 index로 사용함Step 4...

    [Pandas] Pandas01 - Chipotle 풀이

    Step 1. Import the necessary libraries-> import pandas as pd import numpy as np Step 2. Import the dataset from this address.Step 3. Assign it to a variable called chipo.-> url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv'chipo = pd.read_csv(url,sep='\t') ‘\t’ 탭/indent를 의미함url을 csv로 읽어온다.Step 4. See the first 10 entries-> chipo.head(10) A : Step 5. What is the n..

    Pandas Exercise

    https://github.com/guipsamora/pandas_exercises 위의 Pandas Exercise 문제 풀이입니다아래의 순서에 따라 진행할 것 입니다. 01 - Getting & Knowing Your Data02 - Filtering & Sorting03 - Grouping04 - Apply05 - Merge06 - Stats07 - Visualization08 - Creating Series and DataFrames09 - Time Series10 - Deleting11 - Indexing