How to convert DataFrame column to Rows in Python?
Try using pandas melt
dataT = pd.DataFrame({&quot;userID&quot;:[1,2,3],&quot;date&quot;:[&quot;2020-01-01&quot;,&quot;2019-01-02&quot;,&quot;2020-08-12&quot;],&quot;-7&quot;:[0,1,1],&quot;-6&quot;:[1,0,0],&quot;-5&quot;:[0,0,0]})

Input:

dataT.melt(value_vars= [&quot;-7&quot;,&quot;-6&quot;,&quot;-5&quot;], value_name=&quot;count&quot;)

Output:

Update
By taking the comment by Benji the code would be:
dataT.melt(id_vars= [&quot;userID&quot;,&quot;date&quot;], value_name=&quot;count&quot;)

With output: