Tag: N
Pandas : Select first or last N rows in a Dataframe using head() & tail()
In this article we will discuss how to select top or bottom N number of rows in a Dataframe using head() & tail() functions. Select first N Rows from a Dataframe using head() function pandas.DataFrame.head() In Python’s Pandas module, the Dataframe class provides a head() function to fetch top rows from a Dataframe i.e. Advertisements …
Pandas : Select first or last N rows in a Dataframe using head() & tail()Read More
Python: How to get first N characters in a string?
In this article, we will discuss how to fetch/access the first N characters of a string in python. This N can be 1 or 3 etc. Table Of Contents Get the first character of a string in python Get first N characters in a string Get first three characters of a string in python Get …
Python: How to get Last N characters in a string?
In this article, we will discuss how to fetch the last N characters of a string in python. This N can be 1 or 4 etc. In python, a String is a sequence of characters, and each character in it has an index number associated with it. For example, we have a string variable sample_str …
Python: Get last N lines of a text file, like tail command
In this article, we will discuss a memory-efficient solution to read the last line or last N lines from a text or CSV file in python. Then we will also see how to real only last line or check if the last line in the file matches the given line. We have created a function …
Python: Get last N lines of a text file, like tail commandRead More
Remove last N characters from string in Python
In this article we will discuss different ways to delete last N characters from a string i.e. using slicing or for loop or regex. Remove last N character from string by slicing In python, we can use slicing to select a specific range of characters in a string i.e. Advertisements str[start:end] It returns the characters …
Remove first N Characters from string in Python
In this article we will discuss ways to remove first N characters from a string either by using slicing or regex or simple for loop. Use slicing to remove first N character from string in python In python, we can use slicing to select a specific range of characters in a string i.e. Advertisements str[start:end] …
Linux: Find files modified in last N minutes
In this article, we will discuss how to find files in Linux / Unix, that are modified in last few minutes using the find command. Table of Contents Overview of find command in Linux. Syntax of find command with “-mmin n” option. Find files modified in last 5 minutes in Linux. Find files modified in …
Pandas: Drop first N rows of dataframe
In this article, we will discuss different ways to delete first N rows of a dataframe in python. Use iloc to drop first N rows of pandas dataframe In Pandas, the Dataframe provides an attribute iloc to select a portion of the dataframe using position based indexing. This selected portion can be a few columns …
Drop last N rows of pandas dataframe
In this article, we will discuss different ways to delete last N rows of a dataframe in python. Use iloc to drop last N rows of pandas dataframe In Pandas, the Dataframe provides an attribute iloc to select a portion of the dataframe using position based indexing. This selected portion can be a few columns …
How to delete first N columns of pandas dataframe
In this article, we will discuss different ways to delete first N columns of a dataframe in python. Use iloc to drop first N columns of pandas dataframe In Pandas, the Dataframe provides an attribute iloc to select a portion of the dataframe using position based indexing. This selected portion can be a few columns …