TypeError Traceback (most recent call last) <ipython-input-94-498175e5b97d> in <module> 8 _x = mm_bfl['歌单标题'].tolist() 9 _y = mm_bfl['歌单播放量'].tolist() ---> 10 mm_bfl = plt(x=_x,y=_y,chart='barh',title='网易云音乐华语歌单播放 TOP12',loc='left',size=10,color="red") 11 mm_bfl TypeError: 'module' object is not callable,什么意思,正确代码怎么写
时间: 2024-03-22 08:39:53 浏览: 16
这个错误提示的意思是你尝试调用一个模块而不是模块中的函数或类。你需要在模块名后面加上函数名或类名才能正确调用。在这个代码中,你需要将 `plt` 改为 `plt.barh` 才能正确调用 `barh` 函数。正确代码如下:
```python
import matplotlib.pyplot as plt
_x = mm_bfl['歌单标题'].tolist()
_y = mm_bfl['歌单播放量'].tolist()
mm_bfl = plt.barh(x=_x, y=_y, color="red")
plt.title('网易云音乐华语歌单播放 TOP12', loc='left', size=10)
plt.show()
```
相关问题
TypeError Traceback (most recent call last) <ipython-input-21-656cfe61f5bf> in <module>() 5 epochs=2, 6 validation_split=0.2, ----> 7 shuffle=True) 8 9 TypeError: fit() got an unexpected keyword argument 'batch_size'
这是一个关于 Python 代码中 fit() 函数的 TypeError,可能是由于 fit() 函数没有 batch_size 参数导致的。建议检查一下代码中的 fit() 函数,确认是否有输入正确的参数。如果需要更多的帮助,可以提供更详细的代码和错误信息,我会尽力帮忙解决问题。
TypeError Traceback (most recent call last) <ipython-input-2-b8ec604d943f> in <module>() 1 list1 = [1, 2, 3, 1, 2, 3, 4, 5, 1] ----> 2 list2 = list(set(list1)) 3 print(list2) TypeError: 'list' object is not callable
这个错误的原因是你把一个内置函数 `list()` 的名称赋值给了变量 `list2` ,导致程序无法调用内置函数 `list()` 。你可以尝试使用一个不同的变量名来解决这个问题。以下是一种正确的写法:
```
lst1 = [1, 2, 3, 1, 2, 3, 4, 5, 1]
lst2 = list(set(lst1))
print(lst2)
```
这里我们将变量名 `list1` 改为了 `lst1` ,将变量名 `list2` 改为了 `lst2`。