How-to articles, tricks, and solutions about PYTHON
not None test in Python
In Python, you can check if a variable is not equal to None using the is not operator.
Pandas Merging 101
Here is an example of how to use the pd.merge() function to merge two DataFrames in pandas:
Parsing boolean values with argparse
Here is an example of how to parse boolean values with argparse in Python:
Peak detection in a 2D array
Here is an example of a Python function that can be used to detect peaks in a 2D array:
pg_config executable not found
Check the location of pg_config: Open a terminal and run the command "which pg_config".
pip install mysql-python fails with EnvironmentError: mysql_config not found
This error occurs when the mysql-config command is not in the system's PATH.
Print string to text file
In Python, you can use the built-in open() function to create a text file and write a string to it.
Printing Lists as Tabular Data
Here is an example of how to print a list of lists (a 2D list) as tabular data using Python:
Python `if x is not None` or `if not x is None`?
The proper way to check if a variable x is not None in Python is to use if x is not None.
Python - Count elements in list
You can use the len() function to count the number of elements in a list.