In the documentation, you’ll read that it defaults to None, and you’ll see that in the signature, but really that’s a bit of a misnomer because when the dtype is None, the arange() function itself attempts to figure out what the proper data type for your array should be based on the start, stop, and step values that you provide.Ġ2:04 Really, it does default to None but when it’s None, the behavior is that arange() attempts to figure out the type for you, and this is perfect for most use cases.Ġ2:14 Let’s take a look at the terminal and see how this is actually used in code. It just says how far apart are these evenly spaced values.Ġ1:37 Then finally, the dtype, the only non-numeric parameter, is the type of the elements of the output array. The step is the third numeric parameter, and that defines the difference between consecutive elements in the array.Ġ1:26 This defaults to 1, so it defaults to integer ranges, but it can be any value-a floating-point or integer. stop is the number that defines the end of the array, but it’s not included.Ġ1:03 So if I were to use the arange() function with a start of 1 and a stop of 10, it would include numbers up to and including 9, but it would not include 10, the stop, because the stop is not included in the results. It returns a numpy.ndarray, which for all intents and purposes you can treat as a list when you’re using this function.Ġ0:53 start is the number-and it can be integer or decimal-that defines the first value in the array. It shows you that the arange() function takes in a start, a stop, a step, and then sometimes a dtype (data type). Let’s make it a little more clear by looking at the actual parameters.Ġ0:33 This is directly from the NumPy documentation. So, what is the arange() function? Well, as you might guess from its name, it returns a range of numeric values, when you give it start and stop parameters, and then these values are evenly spaced by a step parameter.Ġ0:23 Quite simply, it just gives you a range of evenly spaced numeric values with a certain start and stop. 00:00 Hi there! In this lesson I’m going to take you through NumPy’s arange() function, its parameters, and how you might go about using it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |