2 issues....Help! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: 2 issues....Help! (/thread-11086.html) |
2 issues....Help! - veve - Jun-21-2018 Hi I have a dataset that contains 3 columns in this form: col1 = 2007-Q1, 2007-Q2, 2007-Q3....etc col2 = 1room,2rooms,3rooms...etc col3 = 24,26,30... etc 1st question: I need to create this output : 2007-Q1 -> 1 room -> 24 2007-Q2 -> 2 rooms -> 26 2007 -Q3 ->3 rooms ->30 Libraries permitted to use only : numpy and matplotlib I am stuck at question 1 for a few days. I have load the dataset using np.loadtxt and tried to create list like this : import numpy as np time = list(data['col']) type = list(data['col2']) value = list(data['col3']) time_type = time + type for c, value in enumerate(qu_flat, 1): print(c,value)Realized the output becomes 1. 2007-Q1 2. 2007 - Q2 3. 2007-Q3 . . 10. 1 room 11. 2 rooms 13. 3 rooms How do i go about to have this output: 1. 2007-Q11room ( example: 2007-Q1 join 1 room) 2. 2007-Q22room 2nd question : I need to check are there any duplicates found between the rows in the same dataset. Is there a way to say start from row = 1, column 1 or search through the rows? Thank you very much! RE: 2 issues....Help! - woooee - Jun-21-2018 You have not declared qu_flat anywhere in the code you posted, and the indentation is off. Note that time and type are already being used by python, so you should use another variable name. RE: 2 issues....Help! - veve - Jun-21-2018 Hi Apologies import numpy as np qu = list(data['col']) flat = list(data['col2']) value = list(data['col3']) time_type = time + type for c, value in enumerate(qu_flat, 1): print(c,value) |