Python max() — A Simple Illustrated Guide

The max() function returns the maximum of the provided arguments. You can pass either an arbitrary number of values, comma-separated, or an iterable as arguments. An optional key function argument allows you to customize the calculation of the maximum by explicitly defining the weight of each value in the iterable that is used as a … Read more

NumPy Reshape 1D to 2D

Problem Formulation: Given a one-dimensional NumPy array. How to create a new two-dimensional array by reshaping the original array so that the new array has x rows and y columns? Here’s an example of what you’re trying to do: # Given: [0 1 2 3 4 5] x = 2 # rows y = 3 … Read more

How To Fix Error: ‘NoneType’ Object Has No Attribute ‘Group’?

Summary: NoneType attribute error occurs when the type of object being referenced is None. To handle this error you can either use the try-except blocks or you may also use if-else statements according to your requirement. In this article, you will learn about attribute errors with the help of numerous scenarios/examples where you come across … Read more

How to Create a Sequence of Evenly Spaced Values [Vanilla Python & Numpy Linspace]

Problem: How to create a sequence of evenly-spaced values Using pure, vanilla Python, and Using NumPy’s linspace() method. Example: Given three arguments: start=10, stop=20, number_of_values=11. How do you create a sequence of 11 values x0, x1, …, x10 where two subsequent values xi and x(i-1) have the same distance for all i in {0, …, … Read more

How To Install pip On Windows?

Summary: Download get-pip.py file in the desired folder ➨ Open command prompt and navigate to the location of the downloaded file and install PIP using the following command : python get-pip.py Overview pip is a package management tool in Python that allows us to install and manage external Python libraries and dependencies that are not … Read more

Python tuple() — A Simple Guide with Video

Python’s built-in tuple() function creates and returns a new tuple object. When used without an argument, it returns an empty tuple. When used with the optional iterable argument, it initializes the new tuple with the elements in the iterable. Read more about tuples in our full tutorial about Python Tuples. Usage Learn by example! Here … Read more

How to Create a Sequence of Linearly Increasing Values with Numpy Arange?

Problem: How to create a sequence of linearly increasing values? Solution: Use NumPy’s arange() function. The np.arange([start,] stop[, step]) function creates a new NumPy array with evenly-spaced integers between start (inclusive) and stop (exclusive). The step size defines the difference between subsequent values. For example, np.arange(1, 6, 2) creates the NumPy array [1, 3, 5]. … Read more

Python list() — A Simple Guide with Video

Python’s built-in list() function creates and returns a new list object. When used without an argument, it returns an empty list. When used with the optional iterable argument, it initializes the new list with the elements in the iterable. Read more about lists in our full tutorial about Python Lists. Usage Learn by example! Here … Read more

How to Initialize a NumPy Array with Zeros and Ones

Numpy is a popular Python library for data science focusing on linear algebra. In this article, you’ll learn how to initialize your NumPy array. How to Initialize a NumPy Array with Zeros? To initialize your NumPy array with zeros, use the function np.zeros(shape) where shape is a tuple that defines the shape of your desired … Read more