plt.figure(figsize=(10,8))
plt.scatter(df['attacker_size'][df['year'] == 298],
# attacker size in year 298 as the y axis
df['defender_size'][df['year'] == 298],
# the marker as
marker='x',
# the color
color='b',
# the alpha
alpha=0.7,
# with size
s = 124,
# labelled this
label='Year 298')
Run Code Online (Sandbox Code Playgroud)
在上面从Matplotlib的Scatterplot收集的代码片段中,有什么必要plt.figure()?
我有一个如下所示的数据框:
gender doctor name
female A
male B
male A
female C
female B
Run Code Online (Sandbox Code Playgroud)
如何根据医生的姓名进行性别的价值计数?
我有一个名为"admissions"的数据集.
我试图在一个简单的数据集上进行保持验证.为了对数据集的索引进行排列,我使用以下命令:
import numpy as np
np.random.permutation(admissions.index)
Run Code Online (Sandbox Code Playgroud)
np.random.seed()在排列之前我需要使用吗?如果是这样,那么为什么以及np.random.seed(number)代表的数字是什么?
开发总结此数据的频率分布。此数据是一个对象在 20 天内的需求。
2 1 0 2 1 3 0 2 4 0 3 2 3 4 2 2 2 4 3 0. 任务是在 jupyter notebook 中创建一个表,其中包含 Demand 和 Frequency 列。注意:需求必须按升序排列。这就是我所做的。
list_of_days = [2, 1, 0, 2, 1, 3, 0, 2, 4, 0, 3, 2 ,3, 4, 2, 2, 2, 4, 3, 0] # created a list of the data
import pandas as pd
series_of_days = pd.Series(list_of_days) # converted the list to series
series_of_days.value_counts(ascending = True) # the frequency was …Run Code Online (Sandbox Code Playgroud)