2

I'm looking at popularity of food stalls in a pop-up market:

     Unnamed: 0  Shop1  Shop2  Shop3    ...  shop27  shop28  shop29  shop30  shop31  shop32  shop33  shop34
0             0    484    516    484    ...     348     146    1445    1489     623     453     779     694
1             1    276    564    941    ...    1463     178     700     996    1151     364     111    1243
2             2     74   1093    961    ...    1260    1301    1151     663    1180     723    1477    1198
3             3    502    833     22    ...     349    1105     835       1     938     921     745      14
4             4    829    983    952    ...     568    1435     518     807     874     197      81     573
..          ...    ...    ...    ...    ...     ...     ...     ...     ...     ...     ...     ...     ...
114         114      1    187    706    ...     587    1239    1413     850    1324     788     687     687
115         115    398    733    298    ...     864     981     100      80    1322     381     430     349
116         116     11    312    904    ...      34     508     850    1278     432     395     601     213
117         117    824    261    593    ...    1026     147     488      69      25     286    1229    1028
118         118    461    966    183    ...     850     817    1411     863     950     987     415     130

I then summarize the overall visits and split into bins (pd.cut(df.sum(axis=0),5,labels=['lowest','lower','medium','higher','highest'])):

Unnamed: 0     lowest
Shop1          medium
Shop2          medium
Shop3           lower
Shop4           lower
...            ...
shop31         higher
shop32         medium
shop33         higher
shop34         higher

I then want to see popularity of each category over time, manual example:

    6891-33086 33087-59151 59152-85216 85217-111281 111282-137346
0            0        1373        3546        13999          1238

How can I do this with python?

developer1
  • 35
  • 4
  • 1
    Consider posting a code snippet to reproduce a sample DataFrame, as well as the expected output. – hilberts_drinking_problem Apr 03 '20 at 22:23
  • I used `df = pd.read_csv('1.csv')`. I can post a CSV somewhere if helps? – developer1 Apr 04 '20 at 14:09
  • 1
    They're asking for you to take a look at [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) and provide a smaller sample dataframe that shows more clearly how you use your input to reach your output. For example, in the posted output, what do `85217-111281` represent? And where does the figure 13999 come from? – G. Anderson Apr 06 '20 at 14:27

0 Answers0