How-to articles, tricks, and solutions about PYTHON
How do I get the day of week given a date?
You can use the datetime module in Python to get the day of the week for a given date.
How do I get the full path of the current file's directory?
You can use the os module to get the full path of the current file's directory.
How do I get the last element of a list?
To get the last element of a list, you can use negative indexing.
How do I get the number of elements in a list (length of a list) in Python?
To get the number of elements in a list in Python, you can use the len() function.
How do I get the row count of a Pandas DataFrame?
You can use the shape property of the DataFrame to get the number of rows and columns.
How do I get time of a Python program's execution?
To get the time it takes for a Python program to execute, you can use the time module.
How do I install a Python package with a .whl file?
To install a Python package with a .whl file, you can use the pip command.
How do I install pip on macOS or OS X?
To install pip on macOS or OS X, you need to use the Terminal.
How do I iterate through two lists in parallel?
You can use the zip() function to iterate through two lists in parallel.
How do I list all files of a directory?
In Python, you can use the os module to list all files in a directory.
How do I lowercase a string in Python?
You can use the lower() method to lowercase a string in Python.
How do I make function decorators and chain them together?
Function decorators allow you to wrap a function in another function.
How do I pad a string with zeroes?
You can use the zfill() method to pad a string with zeros on the left side.
How do I parse an ISO 8601-formatted date?
You can use the datetime.fromisoformat() method to parse an ISO 8601-formatted date in Python.
How do I pass a variable by reference?
In Python, you can pass a variable by reference by using the & operator.