Python

pandas series

Pandas Series in Python

Pandas is an open source python library widely used for data science/ data analysis and machine learning tasks. Pandas stands for panel data, referring to tabular format. Installing pandas: This is because pandas is built on top of numpy which provides support for multi-dimensional arrays so it is always good to install with numpy. Pandas …

Pandas Series in Python Read More »

f-strings in Python

Python f-strings or formatted strings are new way of formatting strings introduced in Python 3.6 under PEP-498. It’s also called literal string interpolation. They provide a better way to format strings and make debugging easier too. What are f-strings? Strings in Python are usually enclosed in “ ” (double quotes) or ‘ ‘ ( single …

f-strings in Python Read More »

numpy.tril() in Python

numpy.tril() returns a copy of the array matrix with an element of the lower part of the triangle with respect to k. It returns a copy of array with lower part of triangle and above the kth diagonal zeroed. Syntax: numpy.tril(m,k=0) Parameters: m- number of rows in the array. k-It is optional. Diagonal below which …

numpy.tril() in Python Read More »

numpy.triu() in Python

numpy.triu() returns a copy of the array matrix with an element of the upper part of the triangle with respect to k. It returns a copy of array with upper part of triangle and below the kth diagonal zeroed. Syntax: numpy.triu(m,k=0) Parameters: m- number of rows in the array. k-It is optional. Diagonal above which …

numpy.triu() in Python Read More »

numpy.ravel() in Python

numpy.ravel() is a function present in numpy module which allows us to change a 2 dimensional or multi dimensional array into a contiguous flattened array i.e 1 dimensional array with all input elements and of same type as it. A copy is made only when needed. If input array is masked then returned array is …

numpy.ravel() in Python Read More »

numpy.ndarray.flatten() in Python:

Numpy flatten() converts a multi dimensional array into ‘flattened’ one dimensional array. It returns a copy of the array in one dimension. Now let us see about numpy.ndarray.flatten(). numpy.ndarray.flatten() Syntax: ndarray.flatten(order = ‘C’) Parameters: Returns: A copy of input array, flattened  to 1D array. Example: Flatten an array by row: Flatten an array by column: …

numpy.ndarray.flatten() in Python: Read More »