Pivot Table/Groupby/Sum question

petr.jakes.tpc at gmail.com petr.jakes.tpc at gmail.com
Fri Jan 4 12:50:16 EST 2008


On Jan 4, 4:55 pm, patrick.wa... at gmail.com wrote:
> Petr thanks so much for your input.  I'll try to learnSQL, especially
> if I'll do a lot of database work.
>
> I tried to do it John's way as en exercise and I'm happy to say I
> understand a lot more.  Basically I didn't realize I could nest
> dictionaries like db = {country:{genre:{sub_genre:3}}} and call them
> like db[country][genre][sub_genre].  The Python Cookbook was quite
> helpful to figure out why items needed to be added the way they did.
> Also using the structure of the dictionary was a conceptually easier
> solution than what I found onhttp://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334695.
>
> So, now I need to work on writing it to Excel.  I'll update with the
> final code.
>

Hi, good to know you have succeded. I think it is matter of taste
which way to go (dictionary or database). My feelig is: for data use
database! If you are trying to work with data, you will need it sooner
or later anyway. Again: database is made for data! :-)

Writing your data to excel?
Just save your numbers separated by commas in the file with the
extension csv (my_data.csv) and you can open it directly in Excel.

Good luck :-)

Petr



More information about the Python-list mailing list