By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,760 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,760 IT Pros & Developers. It's quick & easy.

python 1-d to 2-d and vice versa

P: 1
i want to convert a csv file, having data in this form:
customer merchant transaction
john walmart 23
jack walmart 21
mary carrefour 34
mary tesco 12
abbey carrefour 12
john tesco 34
abby tesco 12



into a n*n matrix in this form:

[customer walmart carrefour tesco]
[john 23 0 34]
[jack 21 0 0]
[mary 0 34 0]
[maria 0 0 12]
[abby 0 12 12]


the combination of customer*merchant in the input CSV is unique.

and i also wanna do the vice-versa of the same

would request for a memory and time optimal way...as my resulting matrice would be 0.1MM * 0.1 MM...
Jun 24 '13 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 626
Answered on SO .
Jun 24 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.