Kiran P has Published 123 Articles

How to select the largest of each group in Python Pandas DataFrame?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:49:32

522 Views

IntroductionOne of the most basic and common operations to perform during data analysis is to select rows containing the largest value of some columns within a group. In this post, I will show you how to find the largest of each group within a DataFrame.Problem..Let us understand the task first, ... Read More

How to unpack using star expression in Python?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:44:25

1K+ Views

IntroductionOne of the basic limitation of unpacking is that you must know the length of the sequences you are unpacking in advance.How to do it..random_numbers = [0, 1, 5, 9, 17, 12, 7, 10, 3, 2] random_numbers_descending = sorted(random_numbers, reverse=True) print(f"Output *** {random_numbers_descending}")Output*** [17, 12, 10, 9, 7, 5, 3, ... Read More

How to perform Calculations with Dictionaries in Python?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:41:18

1K+ Views

ProblemYou want to perform various calculations (e.g., minimum value, maximum value, sorting, etc.) on a dictionary of data.Solution.We will create a dictionary with tennis players and their grandslam titles.PlayerTitles = {    'Federer': 20,    'Nadal': 20,    'Djokovic': 17,    'Murray': 3,    'Theim' : 1,    'Zverev': 0 ... Read More

How to compare two DataFrames in Python Pandas with missing values

Kiran P

Kiran P

Updated on 09-Nov-2020 10:36:56

1K+ Views

IntroductionPandas uses the NumPy NaN (np.nan) object to represent a missing value. This Numpy NaN value has some interesting mathematical properties. For example, it is not equal to itself. However, Python None object evaluates as True when compared to itself.How to do it..Let us see some examples to understand how ... Read More

How to write functions in Python that accept any number of arguments

Kiran P

Kiran P

Updated on 09-Nov-2020 10:32:00

1K+ Views

ProblemYou want to write a function that accepts any number of input arguments.SolutionThe * argument in python can accepts any number of arguments. We will understand this with an example of finding out the average of any given two or more numbers. In the below example, rest_arg is a tuple ... Read More

How to use the Subprocess Module in Python?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:29:33

889 Views

Understanding Process -When you code and execute a program on Windows, MAC or Linux, your Operating System creates a process(single).It uses system resources like CPU, RAM, Disk space and also data structures in the operating system’s kernel. A process is isolated from other processes—it can’t see what other processes are ... Read More

How to process iterators in parallel using ZIP

Kiran P

Kiran P

Updated on 09-Nov-2020 10:27:45

238 Views

IntroductionList comprehensions make it easy to take a source list and get a derived list by applying an expression. For example, say that I want to multiply each element in a list with 5. Here, I do this by using a simple for loop.a = [1, 2, 3, 4, 5, ... Read More

How to implement Concurrency with Threads in Python?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:20:23

188 Views

IntroductionPython has different approaches like using threads, subprocesses, generators and other tricks for concurrent programming.Before we go on and implement threads, let us understand what exactly is concurrency.Concurrency is a piece of logic Within a single program that allows to open up many distinct paths of execution, including separate streams ... Read More

How to process excel files data in chunks with Python?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:18:17

2K+ Views

IntroductionIt seems that the world is ruled by Excel. I've been surprised in my data engineering work to see how many of my colleagues are using Excel as a critical tool for making decisions. While I'm not a big fan of MS Office and their excel spread sheets, i will ... Read More

How to implement immutable Data structures in Python?

Kiran P

Kiran P

Updated on 09-Nov-2020 10:16:00

294 Views

ProblemYou need to implement immutable data structures in Python.Introduction..Immutable data structures are very handy when you want to prevent multiple people modifying a piece of data in parallel programming at same time. Mutable data structures( e.g. Array) can be changed at any time while immutable data structures cannot be.How to ... Read More

Advertisements