擅长:python、mysql、java
<p>这对我很有用:</p>
<pre class="lang-python prettyprint-override"><code>import pandas as pd
#initialize the data
x = pd.DataFrame({'User':['A','A','A','B','B','C','C'],'Marketing_Channel':['Marketing_Channel','Email','Paid Search','Email','Paid Search','Email','Paid Search']})
#grouping by user to get the user journey
y = x.groupby('User').agg({'Marketing_Channel': '->'.join}).reset_index()
#group by channel to get the count
z = y.groupby('Marketing_Channel').count()
#make a json out of it
z.to_json()
</code></pre>