Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 2 issues....Help!
#1
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. Wall
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!
Quote
#2
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.
Quote
#3
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)

Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)