# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import pandas as pd

# ##### quiz_1
# - 아래와 같은 데이터 프레임을 만드세요.
# - 아래와 같이 데이터가 나오도록 코드를 추가하시면 됩니다.
# - 점수는 50~100의 숫자가 랜덤으로 들어갑니다.
# - 이름은 아래의 이름에서 랜덤으로 중복되지 않도록 10명을 뽑으세요
# - names = ['Adam', 'Alan', 'Alex', 'Alvin', 'Andrew', 'Anthony', 'Arnold', 'Baldy', 'Baron', 'Billy', 'Boris', 'Bruno', 'Caley', 'Champ', 'Charlie', 'Clark']
# - total 데이터를 나타내는 컬럼을 추가하세요
# - get_grade 함수를 이용해서 total 데이터에 대한 grade 컬럼을 출력하세요
# - 뽑은 데이터의 Grade로 오름차순 하세요
#

# +
number = 10
names = ['Adam', 'Alan', 'Alex', 'Alvin', 'Andrew', 'Anthony', 'Arnold', 'Baldy', 
         'Baron', 'Billy', 'Boris', 'Bruno', 'Caley', 'Champ', 'Charlie', 'Clark']

df = pd.DataFrame(columns=["Name","Math","Science","English"])

# set data
def get_name() :
    return 

# set total

# set grades
def get_grade(point):
    if point >= 270:
        return "A"
    elif point > 240:
        return "B"
    elif point >= 210:
        return "C"
    elif point >= 180:
        return "D"
    else:
        return "F"

# set sort

df = df.reset_index(drop=True)
df

# +
import numpy as np
np.random.randint(50, 100 + 1)



# +
import pandas as pd
import numpy as np
number = 10
names = ['Adam', 'Alan', 'Alex', 'Alvin', 'Andrew', 'Anthony', 'Arnold', 'Baldy', 
         'Baron', 'Billy', 'Boris', 'Bruno', 'Caley', 'Champ', 'Charlie', 'Clark']

df = pd.DataFrame(columns=["Name","Math","Science","English"])

# set data
def get_name() :
    return np.random.choice(names)

def get_score() :
    return np.random.randint(50, 100 + 1)

def get_data(number) :
    name_ls = []
    name = get_name()
    name_ls.append(name)
    while name in list(name_ls) :
        name = get_name()
    for _ in number :
        dic = {
            "Name" = name.
            "English" = get_score(),
            "Math" = get_score(),
            "Science" = get_score(),
        }
    
    
    

# set total

# set grades
def get_grade(point):
    if point >= 270:
        return "A"
    elif point > 240:
        return "B"
    elif point >= 210:
        return "C"
    elif point >= 180:
        return "D"
    else:
        return "F"

# set sort

df = df.reset_index(drop=True)
df
# -



# +
import pandas as pd
import numpy as np
number = 10
names = ['Adam', 'Alan', 'Alex', 'Alvin', 'Andrew', 'Anthony', 'Arnold', 'Baldy', 
         'Baron', 'Billy', 'Boris', 'Bruno', 'Caley', 'Champ', 'Charlie', 'Clark']

df = pd.DataFrame(columns=["Name","Math","Science","English"])

# set data
def get_name() :
    return np.random.choice(names)

def get_score() :
    return np.random.randint(50, 100 + 1)

def get_data(number) :
    df = pd.DataFrame(columns = ["Name", "English", "Science", "Math"])
    for _ in range(number) :
        name = get_name()
        
        while name in list(df["Name"]) :
            name = get_name()
            
        dic = {
            "Name" : name,
            "English" : get_score(),
            "Math" : get_score(),
            "Science" : get_score(),
        }
       
        df.loc[len(df)] = dic
    return df

def get_grade(point):
    if point >= 270:
        return "A"
    elif point > 240:
        return "B"
    elif point >= 210:
        return "C"
    elif point >= 180:
        return "D"
    else:
        return "F"

# set total
df["Total"] = df["English"] + df["Science"] + df["Math"]

# set grades

# -

df = get_data(10)
df["Total"] = df["English"] + df["Science"] + df["Math"]
df
df['Grade'] = df['Total'].apply(get_grade)
df.sort_values(by = ["Grade"], ascending = True)

df.groupby(df.Total).agg(get_grade())

StarcoderdataJupyterScriptsDedupFiltered