For any and all questions relating to Challenge 9 post away!
Whatâs the answer for the stretch questions?
Hello everyone, I hope we are enjoying todayâs challenge.
Kindly drop any questions here and discuss amongst yourselves without sharing answers.
What are the QUESTIONS? Neither the first two nor the âstretchâ ones match up with the âanswersâ! All four questions ask âHOW MANYâ which require integer answers likely > 3 so what is with the float âanswersâ?
The answers were just formatted funny.
The answers are written:
- ANSWER
- ANSWER
thatâs not a decimal, Itâs just denoting question 1, question 2.
Iâm using the df.head(#) function to pull all the rows in the wine.csv data set, but itâs only showing the first 5 rows and the last 5 rows, with a ⌠in the middle of the table. How do I get the full data set to display?
First of, Iâm not sure it a good idea to want to display an entire dataframe. You can pass in a value if to the .head() or .tail() method if you want to see more than the top 5 or bottom 5 rows. For example, if you are interesting in seeing that too 20 rows of a df named data, all you have to do is to run data.head(20).
If you are super interested in seeing every of your rows, just run data, and format your jupyter notebook to allow for displaying the whole dataframe, but this will slow your kernel should it be a very big dataset.
The .head() function is suppose to only show the first 5 rows. Itâs for you to get familiar with how the data is setup without showing every row in the datasets (Imagine trying to print out 100k rows everytime you wanna check what your table looks like)
If you want the entire dataset, you can simply type in df and Jupyter notebooks will format it. However you may want to look at ways to sort the data without having to go throught he entire dataframe.
I donât seem to understand your point here. I will appreciate if you could clarify. Thanks!
You could simply format your answers as float, if you are sure thatâs the problem.
It is perfectly okay. I will leave the message, it allows others to get same answer but with different perspectives.
Oh I was trying to answer the person above. I think they mistook the answers in the multiple choice to the question to be
â1.86, 2.59â, â1.86, 2.48â, â1.86, 2.71â and so on
Instead of
âAnswer to 1: 86, Answer to 2: 59â, âAnswer to 1: 86, Answer to 2: 48â, âAnswer to 1: 86, Answer to 2:71â
They were asking why the answers were all smaller than 3, and not integer numbers. I just wanted to clarify.
THANK YOU Mallowraiin! I didnât think of that.
Thatâs a relief!
Ahh, makes more sense now. I think this is super clear.
Thanks for the clarification!
Hi kw1!
Kelvine95 and Mallowrain made some good points explaining that you probably donât want to show the entire dataframe, and Kelvine95 gave one way you can show the entire dataframe, but hereâs a method that was not mentioned:
Using The iloc Property
The iloc property could help you achieve your objective! More about it can be found here:
https://pandas.pydata.org/docs/reference/api/pandas.Series.iloc.html
It seems that with iloc, we can slice the dataframe. I did some testing and determined that the max rows the jupyter notebook is configured to show is 60, so this is what I did to show the entire dataframe:
print(df[0:60]["Magnesium"])
print(df[60:120]["Magnesium"])
print(df[120:180]["Magnesium"])
I only did this to see if it could be done, though. Iâm not sure if looking at the entire data frame would be useful (even for testing), since the data frame could typically have many more rows in it than just a couple hundred.
In real-life data situations, youâll never want to view the entire data. BUT if you really want to, then you can use the to_string() method and apply that to the DataFrame.
print(dataframe.to_string())
Hi mods! (Iâm guessing thatâs @Kelvine95 and caroLHL?)
Two questions for yall:
- Can I post my answers for the stretch questions?
- When we have a question like this that only mods can answer, whatâs the protocol? Should we just @mention you like I did in this post?
Thanks!!
Can someone please tell me how to delete cells? I accidentally added a cell above and below the one I was working in and I cant run my code. I tried Google, the video tutorial and other tutorials for Jupyter but the command they are telling me to use isnât working. Super frustrating.
The cell I am trying to run code in has an asterisk in the square brackets - I have no idea what I hit on my keyboard to make this happen.
click on the left side of the cell and hit âDâ twice
An interesting thing about stretch questions.
you can combine two datasets indexes with operators when you pass them as arguments.
df[ A & B]
this will result in the intersection of A and B