How-to articles, tricks, and solutions about PYTHON
Extracting extension from filename in Python
You can extract the file extension from a file name in Python by using the os.path module.
Extracting just Month and Year separately from Pandas Datetime column
You can extract the month and year separately from a Pandas datetime column using the dt accessor.
Fastest way to check if a value exists in a list
The fastest way to check if a value exists in a list is to use the in operator.
Filter pandas DataFrame by substring criteria
Here is an example of how you can filter a pandas DataFrame by substring criteria:
Find the current directory and file's directory
To find the current directory in Python, you can use the following code:
Find which version of package is installed with pip
You can use the following command to check the version of a package installed with pip:
Finding and replacing elements in a list
Here is a Python code snippet that demonstrates how to find and replace elements in a list:
Finding the average of a list
Here is a Python code snippet for finding the average of a list of numbers:
Finding the index of an item in a list
To find the index of an item in a list in Python, you can use the index() method of the list.
Get difference between two lists with Unique Entries
You can use the set data type to find the difference between two lists with unique entries.
Get the data received in a Flask request
In a Flask application, you can access the data received in a request using the request object.
Get unique values from a list in python
In Python, you can use the set() function to get the unique values from a list.