-
-
Notifications
You must be signed in to change notification settings - Fork 787
Suggestion to Introduce Type Conversion #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I agree with this suggestion. I found that when I was first learning to use numpy, much of the debugging I had to do centered on the subtleties of arrays vs. lists. An exercise in Episode 5 could center around debugging one of these errors. For example: numbers = [1,2,3]
numbers+1 # produces TypeError
numpy.array(numbers)+1 # produces array([2,3,4]) |
Thank you @alimoges42 for opening this issue to suggest introducing type conversion. I agree with you that knowing about how to convert data types could be useful across disciplines. However, we are limited on being able to introduce new concepts into the lesson due to it already being difficult to fit the current concepts into a standard workshop time frame and not wanting to overload learners with new concepts. To help us determine what new concepts to include, we are trying to clearly determine the value of adding any newly proposed concept to the lesson and how it can be incorporated into the inflammation story line. To reach those goals, could you clarify how knowing about type conversion reinforces learners' understanding of data types in the context of the lesson and suggest a way of tying the type conversion introduction and example into the inflammation story line? @djangraw , thanks for commenting to let us know you agree with including type conversion and giving a code example. To help with what I asked Aaron above, could you modify the example (or suggest how) to make it meaningful in the context of working with the inflammation data. I think being able to show the type conversion is relevant to working with our dataset in the context of our lesson would help support its inclusion. |
Well, Lesson 5 doesn't seem to include the inflammation data at all, so it might be a bit strange to introduce it just for this. I might suggest adding this example after the code blocks following "There are many ways to change the contents..." and just before "While modifying in place,". You could add something like: You might be tempted to perform arithmetic on lists of numbers the same way you would with single numbers, but that will produce an error because numbers and lists are different types.
For mathematical operations like this, the array can be converted to a numpy array:
If you'd really like to put this in context, it might be best in Lesson 6 where we return to the data. We could say that it would be tempting to do mean subtraction like this:
|
It appears that the topic of type conversion is not covered in any of the episodes of this lesson (as far as I can tell). I think that the concept of type conversion is useful for learners because it is a problem encountered throughout all domains of data science and research.
I suggest that type conversion be integrated into the content of Episode 1 because it reinforces the learners' understanding of how data types work, and furthermore it shows users that there are simple ways to coerce data types. I don't think the material needs to be too advanced - even a simple demonstration of converting a number using
float()
andstr()
can show learners that the two data types behave differently. This alone is an incredibly simple demonstration that I think can help users develop a better grasp of how data types work, and these functions are also very useful in everyday problems at all levels of data science.If desired, type conversion may further be reinforced in later episodes (i.e. in Episode 5 one could convert a list to a numpy array or vice versa). Again, I don't think it would be necessary to spend too much time on it, and it could help learners with some of the mental barriers in understanding how and why data types work the way they do.
The text was updated successfully, but these errors were encountered: