- feedback about business: how these results can be important?
- how to optimise this code? The output gets too long.
display_table(android_final[1:],-4) # genres ```
<!-- 2. copy and paste the URL of the last mission screen of the Guided Project below-->
<!-- 3. upload your notebook (.ipynb file) below-->
your question is quite confusing to profer a solution.
What do you mean by “profess a solution”?
Which question is confusing?
About the second question, I ask how to optimize the function display_table to limit the output in some rows, such as the DataFrame.head() in Pandas.
sorry that was a typo
@monorienaghogho I am of the opinion that you can’t do this without using pandas, I’d love to know your thought.
Hi @karina.condeixa, @OlutokiJohn
If I understood correctly, you’d like
display_ table to output a Pandas DataFrame.
table_display variable is currently a list of tuples:
You can change a list of tuples into a DataFrame.
Put the first and second entries into separate lists and put these two lists into a dictionary:
Dict[key1: list1, key2: list2].
Change the dictionary to a DataFrame.
I actually tried that and it gave me a type error i.e nonetype, i don’t know if it’d work for @karina.condeixa
display_table function does not return anything - which is None.
If you want
pd.DataFrame(display_table) the function should return the dictionary.
oh okay, @karina.condeixa actually wants the output minimized just like we do in pandas i.e instead of displaying all we just display maybe like the first 5 or thereabout, I tried iterating over the display_table but it keeps giving me an error that I can’t iterate over a nonetype so it’s not the desired output should be a dataframe per se
thanks for your answer.
But, I don’t want to transform it in a DataFrame, I just want to have an output that shows the first (5, for example) top values.
I got it, thanks.
And what is the advantage of working with lists of lists instead of transforming them into DataFrames?
Slice your list of lists:
If you want you list in a particular order, you can sort before slicing.