将下列代码重新定义完整def get_tag(df): df = df['tag'].str.split('-') datalist = list(set(x for data in df for x in data)) return datalist df_tag = get_tag(df) print(df_tag) def get_lx(x,i): if i in str(x): return 1 else: return 0 for i in list(df_tag): df[i] = df['tag'].apply(get_lx,i=f'{i}') Series = df.iloc[:,7:].sum().sort_values(ascending=False) df_tag = [tag for tag in zip(Series.index.tolist(),Series.values.tolist())] df_iex = [index for index in Series.index.tolist()][:20] df_tag = [tag for tag in Series.values.tolist()][:20] df_tagiex = get_matplot(x=df_iex,y=df_tag,chart='plot',title='网易云音乐华语歌单标签图',size=10,ha='center',color=color[3]) print(df_tagiex)
时间: 2024-03-21 22:39:30 浏览: 60
ng-datalist:AngularJS指令提供带有可搜索下拉列表的文本输入
好的,这里是完整的代码定义:
```python
def get_tag(df):
df = df['tag'].str.split('-')
datalist = list(set(x for data in df for x in data))
return datalist
df_tag = get_tag(df)
print(df_tag)
def get_lx(x,i):
if i in str(x):
return 1
else:
return 0
for i in list(df_tag):
df[i] = df['tag'].apply(get_lx,i=f'{i}')
Series = df.iloc[:,7:].sum().sort_values(ascending=False)
df_tag = [tag for tag in zip(Series.index.tolist(),Series.values.tolist())]
df_iex = [index for index in Series.index.tolist()][:20]
df_tag = [tag for tag in Series.values.tolist()][:20]
df_tagiex = get_matplot(x=df_iex,y=df_tag,chart='plot',title='网易云音乐华语歌单标签图',size=10,ha='center',color=color[3])
print(df_tagiex)
```
需要注意的是,这里的代码依赖于DF数据和get_matplot函数。如果您没有这些数据和函数,那么这段代码将无法运行。
阅读全文