用python淘汰excel篇:求客户买过的商品及次数最大值
max = df.groupby("客户")['商品'].apply(lambda x: x.value_counts().head(1))
max = df.groupby("客户")['商品'].apply(lambda x: x.value_counts().head(1))
dfto1['新加'] = dfto1['bv'].fillna(method='ffill')
dfto1['新加'] =dfto1['bv'].replace(["BV1jb411H7aa","BV1vb411K737","BV1Ut411p7xq","BV1Nb411h7bc","BV1Sb411G726"],["a1","a2","a3","a4","a5"],)
print(dfto1.head(5))
dfto1['newone'] = list(map(lambda s:s.strip("【").strip("】"),dfto1['title'].astype(str))) #把头尾的某个字符去掉,多用于去除空格
print(dfto1.head(10))
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] #不加下面这两行显示的标题会乱码
plt.rcParams['axes.unicode_minus'] = False
df各档分值4.plot.bar() #柱状图(条形图)
df各档分值4.plot.bar(stacked = True) #柱状图堆积图
df各档分值4.plot.barh() #条型图
df各档分值4.plot.barh(stacked = True) #条型堆积图
df各档分值4.plot.hist(alpha=0.5) #直方图
df各档分值4.plot.hist(alpha=0.5,stacked=True,bins=20) #堆积直方图
df各档分值4.plot.box() #箱型图
df各档分值4.plot.area() #区域图
df各档分值4.plot.scatter(x="对应15档",y="分值") #散点图
df各档分值4.plot.hexbin(x="对应15档",y="分值",gridsize=25) # 蜂巢图
df各档分值4.plot(table=True)
df各档分值4['分值'].plot.pie(subplots=True,autopct="%.2f", figsize=(8,4),title="测试",rot=0)
plt.show()