python - 忽略无效数据的 Pandas 直方图;限制 x 范围
问题描述
我有一个数据框,其中包含文本和数字数据的混合,其中一些值-999
表示丢失或无效数据。作为一个玩具示例,假设它看起来像这样:
import pandas as pd
import matplotlib.pyplot as plt
dictOne = {'Name':['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth'],
"A":[1, 2, -3, 4, 5, -999, 7, -999, 9],
"B":[4, 5, 6, 5, 3, -999, 2, 9, 5],
"C":[7, -999, 10, 5, 8, 6, 8, 2, 4]}
df2 = pd.DataFrame(dictOne)
df2.hist('C', bins = 1000)
plt.xlim=([0, 10])
我试图排除这些-999
值。Pandas 有没有简单的方法来做到这一点?
另外,在我的示例代码中,为什么 x 轴不限于 [0,10] 范围?
解决方案
推荐阅读
- swift - 滚动到 WKWebView 的底部,macOS?
- javascript - 如何在 Angular 6 中格式化日期?
- angular - JSONP 调用成功,但出现错误:JSONP 注入脚本未调用回调
- python - 如何对 1000 个独特的时间序列数据进行数据探索?
- amazon-web-services - 如何在 AWS Lambda 中正确创建身份验证中间件
- c++ - GTest:使用 std::function 参数化测试时的 Valgrind 警告
- python - sklearn中字母的N-gram
- python - 尝试使用枕头/PIL 库时不理解此 FileNotFoundError
- c# - 具有展开和聚合的 MongoDB 性能
- php - mysqli更新查询未捕获异常