In [1]:
"My name is %s" % "Tom"
Out[1]:
In [2]:
"{1}'s score is {0}, {0}, {0}, {0}, {0}, {0}, {0}".format(100, "Jane")
Out[2]:
In [4]:
a = 100
if a %2 == 0:
print('짝수')
else:
print('홀수')
In [8]:
sex = "boy"
pushup = 5
if sex == "boy":
if pushup >=10:
grade = "Pass"
else:
grade = "Fail"
print(grade)
In [9]:
def twotimes(x):
y = 2 * x
return y
In [10]:
twotimes(2)
Out[10]:
In [12]:
for i in range(4):
print("*")
In [15]:
for i in range(6):
n1 = i + 1
for j in range(6):
n2 = j + 1
print(n1, n2)
In [22]:
tips = sns.load_dataset('tips')
In [21]:
import seaborn as sns
In [23]:
tips.tail()
Out[23]:
In [24]:
tips['tip_pct'] = tips['tip'] / tips['total_bill']
In [25]:
tips.tail()
Out[25]:
In [26]:
tips.describe()
Out[26]:
In [27]:
tips.groupby('sex').count()
Out[27]:
In [28]:
tips.groupby(['sex', 'smoker']).size()
Out[28]:
In [31]:
tips.pivot_table("tip_pct", "sex", "smoker", aggfunc="count", margins=True)
Out[31]:
In [32]:
tips.groupby(["sex", "smoker"])[["tip", "tip_pct"]].describe()
Out[32]:
In [36]:
def peak_to_peak(x):
return x.max() - x.min()
tips.groupby(['sex', 'smoker'])[['tip']].agg(peak_to_peak)
Out[36]:
In [37]:
tips.groupby('sex').count()
Out[37]:
In [ ]:
In [ ]: