【发布时间】:2019-05-06 23:39:07
【问题描述】:
我有一个数据框,其中包含文本和数字数据的混合,-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] 范围?
【问题讨论】: