Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

Get list from pandas dataframe column or row?

$
0
0

I have a dataframe df imported from an Excel document like this:

cluster load_date   budget  actual  fixed_priceA   1/1/2014    1000    4000    YA   2/1/2014    12000   10000   YA   3/1/2014    36000   2000    YB   4/1/2014    15000   10000   NB   4/1/2014    12000   11500   NB   4/1/2014    90000   11000   NC   7/1/2014    22000   18000   NC   8/1/2014    30000   28960   NC   9/1/2014    53000   51200   N

I want to be able to return the contents of column 1 df['cluster'] as a list, so I can run a for-loop over it, and create an Excel worksheet for every cluster.

Is it also possible to return the contents of a whole column or row to a list? e.g.

list = [], list[column1] or list[df.ix(row1)]

Viewing all articles
Browse latest Browse all 13921

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>