thispointer.com thispointer.com

Python: Get difference between two datetimes in seconds

Python provides a module datetime for manipulation of date and time. It consists of following classes, datetime.date : An object of date class specifies a date using year, month and daydatetime.time : An object of time class specifies a timestamp using hour, minute, second, microsecond, and tzinfo.datetime.datetime: An object of datetime is a combination of a date and a time.datetime.timedelta: A duration, that represents the...

thispointer.com thispointer.com

Python: Get difference between two datetimes in minutes

In this article, we will discuss how to get the difference between two datetimes in minutes in python. Python provides a module datetime for manipulation of date and time. It consists of following classes, datetime.date : An object of date class specifies a date using year, month and daydatetime.time : An object of time class specifies a timestamp using hour, minute, second, microsecond, and tzinfo.datetime.datetime: An object of...

thispointer.com thispointer.com

Python String count() function

In this article, we will discuss how to use the count() function of string in python. In python, the string class provides a function count() to get the occurrence count of a sub-string in a string or a portion of string. Syntax of str.count() str.count(sub_string, start, end) Arguments: sub_string: A string or a character, whose occurrence in string has to be counted.start: (Optional) The starting index position of the string, from...

thispointer.com thispointer.com

Pandas: Select columns based on conditions in dataframe

In this article, we will discuss how to select dataframe columns based on conditions i.e. either a single condition or multiple conditions. Let’s start this with creating a dataframe first, import pandas as pd # List of Tuples empoyees = [(11, 34, 78, 5, 11, 56), (12, 31, 98, 7, 34, 78), (13, 16, 11, 11, 56, 41) , (89, 41, 12, 12, 78, 78)] # Create a DataFrame object df = pd.DataFrame(...

thispointer.com thispointer.com

Pandas: Select dataframe columns containing string

In this article, we will discuss how to select dataframe columns which contains a given string or a sub-string. Table of Contents Select columns containing a string in Pandas Dataframe.Select columns not containing a string in Pandas Dataframe.Select columns containing a sub-string in Pandas Dataframe. Let’s start this with creating a dataframe first, import pandas as pd # List of Tuples data = [('FA', 'AA', 'SJ', 'AS', 'B1'), ...

thispointer.com thispointer.com

Find the smallest file in a directory using python

In this article, we will discuss how to find the smallest file in a directory and its sub-directories using python. Table of contents Find the smallest file in a directory using python.Find the smallest file in a directory and its sub-directories using python. Get the smallest file in a directory using python In python, the glob module provides a function glob() to find files/directories in a given directory based on the matching...

thispointer.com thispointer.com

Python- Find the largest file in a directory

In this article, we will discuss how to find the largest file in a directory and its sub-directories using python. Table of contents Find the largest file in a directory using python.Find the largest file in a directory and its sub-directories using python. Get the largest file in a directory using python In python, the glob module provides a function glob() to find files/directories in a given directory based on the matching pattern....

thispointer.com thispointer.com

Python: Get list of files in directory sorted by name

In this article, we will discuss different ways to get list of all files in a directory / folder sorted by name in python. Table of contents Get list of files (file paths) in directory sorted by name.Get list of file names in directory sorted by name.Get list of files (file paths) in directory and sub-directories sorted by name. Get list of files in directory sorted by name using glob() In python, the glob module provides a function...

thispointer.com thispointer.com

Python: Get list of files in directory sorted by size

In this article, we will discuss different ways to get list of all files in a directory / folder sorted by size. Table of contents Get list of files (file paths) in directory sorted by size.Get list of file names in directory sorted by size.Get list of files (file paths) in directory and sub-directories sorted by size. Get list of files in directory sorted by size using glob() In python, the glob module provides a function glob() to...

thispointer.com thispointer.com

Python Get list of files in directory with size

In this article, we will discuss different ways to get list of all files in a directory or folder along with size in python. Table of contents Get list of files (file paths) in directory with size.Get list of file names in directory with size.Get list of files (file paths) in directory and sub-directories with size. Get list of all files in directory with size using glob() In python, the glob module provides a function glob() to find...