## Decorators in Python – How to enhance functions without changing the code?

Decorators in python allow you to dynamically change the functionality of another function, without altering it’s code. What? Is that possible? Yes. This covers: 1. What is a decorator and how to create one? 2. Easier way to decorate functions 3. Class decorators 4. Problem with docstrings on decorated functions and how to solve. What …

Decorators in Python – How to enhance functions without changing the code? Read More »

## Generators in Python – How to lazily return values only when needed and save memory?

Generators in python provide an efficient way of generating numbers or objects as and when needed, without having to store all the values in memory beforehand. Introduction You can think of Generators as a simple way of creating iterators without having to create a class with __iter__() and __next__() methods. So how to create a …

Generators in Python – How to lazily return values only when needed and save memory? Read More »

## Iterators in Python – What are Iterators and Iterables?

Iterable in Python is any object that can be looped over. In order for an iterable to be looped over, an iterable needs to be converted to an iterator using the __iter__() method. Once created, it is actually the iterator that gets iterated over. This is also what happens internally when you run a for-loop. …

Iterators in Python – What are Iterators and Iterables? Read More »

## Python Module – What are modules and packages in python?

Any Python file with a .py extension is a Module in Python. A python package is a collection of such modules along with a __init__.py file. Let’s understand how to work with modules and packages with clear examples. Introduction When you work on python projects, it’s not a good practice to have all you python …

Python Module – What are modules and packages in python? Read More »

## Object Oriented Programming (OOPS) in Python

Object oriented programming is an effective way of writing code. You create classes which are python objects, that represented meaningful entities which defines its own behaviour (via methods) and attributes. Let’s understand what a class is and the concepts behind Object Oriented Programming in Python Everything you have encountered so far in Python, such as …

## Conda create environment and everything you need to know to manage conda virtual environment

Typical python projects uses multiple packages for various tasks. And some of the packages are shared between projects as well. Sharing same packages between projects can cause problems. How? When you update one of the packages used in a project, it might cause compatibility issues in the other packages that use it. On upgrading, it …

## How to use Numpy Random Function in Python

How to use numpy.random.rand() function ? numpy.random.rand() function is used to generate random float values from an uniform distribution over [0,1). These values can be extracted as a single value or in arrays of any dimension. In this article, you will learn about various use cases of this function. Structural overview of numpy.random.rand() Syntax: numpy.random.rand(d0, …

## Partial Correlation

What is Partial Correlation and it’s purpose Partial correlation is used to find the correlation between two variables (typically a dependent and an independent variable) with the effect of other influencing variables being controlled. For example, if there are three variables ‘A’, ‘B’, ‘Z’, If you want to find the relationship between ‘A’ and ‘B’ …

## Chi-Square test – How to test statistical significance for categorical data?

What is chi-square test and its purpose? Chi-square test was invented in the year ‘1900’ by the revered mathematician ‘Karl Pearson’. Chi-square test, also written as χ2 test is used to determine whether there is a statistically significant difference between the observed frequency and the expected frequency in one or more categories of the contingency …

Chi-Square test – How to test statistical significance for categorical data? Read More »

## Numpy Reshape – How to reshape arrays and what does -1 mean?

How to reshape a numpy array? The numpy.reshape() function is used to reshape a numpy array without changing the data in the array. It is a very common practice to reshape arrays to make them compatible for further calculations.

## Pandas Sample – Randomly Sample Rows From Dataframe

Use the pandas.DataFrame.sample() method from pandas library to randomly select rows from a DataFrame Randomly selecting rows can be useful for inspecting the values of a DataFrame.

## Pandas Iterate Over Rows

Pandas DataFrame is used very popularly to store tabular data. Very often, we need to iterate over rows of the dataframe to perform various operations. This is a way of navigating the DatraFrame.

## Pandas Describe

How to use Pandas Describe function? The pandas.describe function is used to get a descriptive statistics summary of a given dataframe. This includes mean, count, std deviation, percentiles, and min-max values of all the features. On applying pandas describe function to a dataframe, the result is also returned as a dataframe . This dataframe will …

## Pandas Dataframe.duplicated()

The pandas.DataFrame.duplicated() method is used to find duplicate rows in a DataFrame. It returns a boolean series which identifies whether a row is duplicate or unique. In this article, you will learn how to use this method to identify the duplicate rows in a DataFrame. You will also get to know a few practical tips …

## Creating pandas series from dictionary

Pandas Series is a 1-dimensional array like object which can hold data of any type. You can create a pandas series from a dictionary by passing the dictionary to the command: pandas.Series(). In this article, you will learn about the different methods of configuring the pandas.Series() command to make a pandas series from a dictionary …

## Pandas Head – How to get the first few rows?

pandas.head() function is used to access the first n rows of a dataframe or series. It returns a smaller version of the caller object with the first few entries.

## RegEx Replace values using Pandas

RegEx (Regular Expression) is a special sequence of characters used to form a search pattern using a specialized syntax While working on data manipulation, especially textual data, you need to manipulate specific string patterns. These may include retrieving hashtags from a tweet, extracting dates from a text, or removing website links. Pandas replace() function is …

## Pandas Histogram

Let’s understand how to create histogram in pandas and how it is useful. Histograms are very useful in statistical analysis. Histograms are generally used to represent the frequency distribution for a numeric array, split into small equal-sized bins. As we used pandas to work with tabular data, it’s important to know how to work with …