小编Mai*_*lam的帖子

mattlotlib中plt.figure()的必要性是什么?

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()

python matplotlib

16
推荐指数
2
解决办法
3万
查看次数

在熊猫中,如何根据另一个分类列执行性别(或任何分类变量)的值计数?

我有一个如下所示的数据框:

gender   doctor name
female       A
 male        B
 male        A
female       C
female       B
Run Code Online (Sandbox Code Playgroud)

如何根据医生的姓名进行性别的价值计数?

python pandas

4
推荐指数
1
解决办法
2479
查看次数

numpy.random.seed()有什么用?它有什么区别吗?

我有一个名为"admissions"的数据集.

我试图在一个简单的数据集上进行保持验证.为了对数据集的索引进行排列,我使用以下命令:

import numpy as np
np.random.permutation(admissions.index)
Run Code Online (Sandbox Code Playgroud)

np.random.seed()在排列之前我需要使用吗?如果是这样,那么为什么以及np.random.seed(number)代表的数字是什么?

python random numpy

3
推荐指数
1
解决办法
5839
查看次数

如何使用尽可能少的代码在 Jupyter notebook 中使用 Python 在给定数据上创建频率分布表?

开发总结此数据的频率分布。此数据是一个对象在 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)

python statistics pandas jupyter-notebook

-2
推荐指数
1
解决办法
2万
查看次数