Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 仅打印频率大于2的字符串_Python_Pandas_Plot - Fatal编程技术网

Python 仅打印频率大于2的字符串

Python 仅打印频率大于2的字符串,python,pandas,plot,Python,Pandas,Plot,在下面的代码中,我希望pd.plot()忽略所有发生1次的情况。i、 例如,仅多次打印列表中的字符串。我该怎么做呢 下面是一些示例代码 import pandas as pd import matplotlib.pyplot as plt x = ['a', 'a', 'b', 'c', 'c', 'c', 'c', 'd', 'e', 'e', 'a', 'e', 'e'] pd.Series(x).value_counts().plot('barh') plt.show() 换句话说,“

在下面的代码中,我希望pd.plot()忽略所有发生1次的情况。i、 例如,仅多次打印列表中的字符串。我该怎么做呢

下面是一些示例代码

import pandas as pd
import matplotlib.pyplot as plt

x = ['a', 'a', 'b', 'c', 'c', 'c', 'c', 'd', 'e', 'e', 'a', 'e', 'e']
pd.Series(x).value_counts().plot('barh')
plt.show()
换句话说,“b”和“d”各出现一次。如何在打印前从绘图中删除这些数据点,即不使用
xlim=[2,4]
。我正试图用类似的方法来处理我的财务数据。我正在读取一个包含大量行的csv文件,因此我希望在打印之前删除字符串的所有单个实例。如果我需要澄清,请告诉我。 使用:

或者,如果需要单线解决方案:

pd.Series(x).value_counts().loc[lambda x: x > 1].plot('barh')
使用:

或者,如果需要单线解决方案:

pd.Series(x).value_counts().loc[lambda x: x > 1].plot('barh')