-
PyKX Project – Netflix – Exercise 8
Hi,
I have a problem with the last exercise (ex8) of the PyKX project.
The problem is to :
Sort the table on the viewsMillion column, from highest to lowest.
Save the result to a new q table called
sortedViews
in q memory space.Here is my attempted solutions:
sortedViews = views.sort_values(by=’viewsMillion’,ascending = False).reset_index(drop=True)
sortedViews = kx.K(sortedViews)
kx.q[‘sortedViews’] = sortedViews(I have even tried the table from ex7. (viewTab) )
other alternative solutions attempts:
#sortedViews = kx.q.sql("select * from viewtab order by viewsMillion desc") # your code here – attempt 1
#sortedViews = kx.q.qsql.select(sortedViews, columns = [‘0′,’title’,’category’,’language’,’viewsMillion’]) – attempt 2– When I run the test function it states I have incorrect number of records even though the previous exercises have passed and ex8 is just asking to sort the table. by views.
pykx.Table(pykx.q(' quizItem success description error --------------------------------------------------------------------------- exercise8 Pass "sortedViews exists in q memory space" "" exercise8 Pass "sortedViews should be a q table" "" exercise8 Fail "sortedViews should have correct number of records" "" exercise8 Pass "sortedViews should have correct columns" "" '))
Log in to reply.