🐍Python

    [Pandas] Pandas03 - Alcohol_Consumption 풀이

    Ex - GroupByIntroduction:¶GroupBy can be summarizes as Split-Apply-Combine.Special thanks to: https://github.com/justmarkham for sharing the dataset and materials.Check out this DiagramStep 1. Import the necessary librariesIn [ ]:import pandas as pd Step 2. Import the dataset from this address.Step 3. Assign it to a variable called drinks.In [5]:url = 'https://raw.githubusercontent.com/justmarkh..

    [Numpy] Numpy 연습문제 51~60

    51. Create a structured array representing a position (x,y) and a color (r,g,b) (★★☆)(hint: dtype)In [4]:Z = np.zeros(10,[('position',[('x',float,1), ('y',float,1)]), ('color', [('r',float,1), ('g',float,1), ('b',float,1)])]) Z Out[4]:array([((0., 0.), (0., 0., 0.)), ((0., 0.), (0., 0., 0.)), ((0., 0.), (0., 0., 0.)), ((0., 0.), (0., 0., 0.)), ((0., 0.), (0., 0., 0.)), ((0., 0.), (0., 0., 0.)), ..

    [Pandas] Pandas02 - Fictional Army 풀이

    Fictional Army - Filtering and SortingIntroduction:This exercise was inspired by this pageSpecial thanks to: https://github.com/chrisalbon for sharing the dataset and materials.Step 1. Import the necessary libraries¶In [1]:import pandas as pd Step 2. This is the data given as a dictionaryIn [2]:# Create an example dataframe about a fictional army raw_data = {'regiment': ['Nighthawks', 'Nighthawk..

    [Pandas] Pandas02 - EURO12 풀이

    Step 1. Import the necessary libraries->import pandas as pd Step 2. Import the dataset from this address.Step 3. Assign it to a variable called euro12.-> euro12 = pd.read_csv('https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/02_Filtering_%26_Sorting/Euro12/Euro_2012_stats_TEAM.csv', sep=',') euro12 Step 4. Select only the Goal column.-> euro12.Goals A : 0 4 1 4 2 4 3 5 4 3 5 ..

    [Numpy] Numpy 연습문제 41~50

    41. How to sum a small array faster than np.sum? -> A = np.arange(10) np.add.reduce(A) A : 45 42. Consider two random array A and B, check if they are equal-> A = np.random.randint(0,2,5) B = np.random.randint(0,2,5) print(np.allclose(A,B)) print(np.array_equal(A,B)) A : FalseFalse 해설 : np.random.randint(~부터,~까지,갯수)로 random한 수를 만든다. 그리고 np.allclose / np.array_equal로 이 둘이 같은지 확인한다. 43. Make an ar..

    [Pandas] Pandas02 - 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') Step 4. How many products cost more than $10.00? -> prices = [float(value[1 : -1]) for value in chipo.it..