It wasn’t a big problem but when I started this project, it did become a pain as I didn’t know that in python 2 we had to convert number to float to get a decimal number where quotient would be 0. I have just started the next section, which is on pandas (Course Link) and right now can’t say what is coming next.
P.S. with different versions of python the syntax used in libraries is also different. Where in python 3 we can use or
and and
inside function calls.
For eg,
import codecademylib
import pandas as pd
df = pd.DataFrame([
['January', 100, 100, 23, 100],
['February', 51, 45, 145, 45],
['March', 81, 96, 65, 96],
['April', 80, 80, 54, 180],
['May', 51, 54, 54, 154],
['June', 112, 109, 79, 129]],
columns=['month', 'clinic_east',
'clinic_north', 'clinic_south',
'clinic_west'])
march_april = df[(df.month == 'March') | (df.month == 'April')]
print(march_april)
Here in the second last line, inside the getter attribute of df
we use | only for python 2, (& also available). Whereas, in python 3 we can use or
and and
. This is not only the case with pandas but also with matplotlib and numpy