Python Seaborn Countplot系列没有';无法识别输入

Python Seaborn Countplot系列没有';无法识别输入,python,pandas,seaborn,Python,Pandas,Seaborn,我正试图将一系列内容绘制成水平条形图,但遇到了一些问题 这是我的系列: HARRASSMENT 2 80149 CRIMINAL MISCHIEF & RELATED OF 62059 ASSAULT 3 & RELATED OFFENSES 61133 GRAND LARCENY 54090 DANGEROUS DRUGS 35407 OFF. A

我正试图将一系列内容绘制成水平条形图,但遇到了一些问题

这是我的系列:

HARRASSMENT 2                     80149
CRIMINAL MISCHIEF & RELATED OF    62059
ASSAULT 3 & RELATED OFFENSES      61133
GRAND LARCENY                     54090
DANGEROUS DRUGS                   35407
OFF. AGNST PUB ORD SENSBLTY &     34810
ROBBERY                           23399
BURGLARY                          22536
FELONY ASSAULT                    21941
GRAND LARCENY OF MOTOR VEHICLE    14094
MISCELLANEOUS PENAL LAW           13307
DANGEROUS WEAPONS                 12090
Name: OFNS_DESC, dtype: int64```


This is what I already tried: 
sns.countplot(y="OFNS_DESC", data=b) , b is the name of my series variable

This is my error:

ValueError: Could not interpret input 'OFNS_DESC'




如果我正确理解了您的数据,那么数字allready表示这些不同类别的计数-因此您实际上只需要一个简单的条形图,而不是countplot

下面是使用pandas/matplotlib和seaborn条形图函数绘制数据的代码:

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

counts = [80149, 62059, 61133, 54090, 35407, 34810, 23399, 22536, 21941, 14094, 13307, 12090]
categories = ['HARRASSMENT 2', 'CRIMINAL MISCHIEF & RELATED OF', 'ASSAULT 3 & RELATED OFFENSES', 'GRAND LARCENY', 'DANGEROUS DRUGS', 'OFF. AGNST PUB ORD SENSBLTY &', 'ROBBERY', 'BURGLARY', 'FELONY ASSAULT', 'GRAND LARCENY OF MOTOR VEHICLE', 'MISCELLANEOUS PENAL LAW', 'DANGEROUS WEAPONS']
sr = pd.Series(data=counts, index=categories)

# | using pandas/matplotlib barplot
plt.figure()
sr.plot.barh()

# | using seaborn barplot
plt.figure()
sns.barplot(x=sr.values, y=sr.index)