【问题标题】:Return max bin value in panda histogram [duplicate]返回熊猫直方图中的最大 bin 值
【发布时间】:2018-03-06 12:27:58
【问题描述】:

我对 Python 非常陌生,我正在寻找解决问题的方法。特别是,我需要在我的直方图中返回箱的最大值......并且不知道如何继续。我的数据框是一个熊猫数据框:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_csv(filename)

bin_array = np.linspace(start=0., stop=10., num=150)
df.series.hist(bins=bin_array)

提前致谢。

【问题讨论】:

标签: python pandas matplotlib histogram


【解决方案1】:

您可能只想直接使用 numpy 的 histogram 函数。这就是 pandas 在幕后调用来生成情节的原因。

bin_array = np.linspace(start=0., stop=10., num=150)
counts, bins = np.histogram(df.series, bins=bin_array)

【讨论】:

    猜你喜欢
    • 2016-11-21
    • 1970-01-01
    • 2021-12-09
    • 2015-07-10
    • 1970-01-01
    • 2019-10-21
    • 2020-10-27
    • 2017-12-12
    • 1970-01-01
    相关资源
    最近更新 更多