How-to articles, tricks, and solutions about PYTHON
if else in a list comprehension
Here's an example of using an if-else statement within a list comprehension:
List attributes of an object
In Python, you can use the built-in function dir() to list the attributes of an object.
Working with UTF-8 encoding in Python source
Here is a code snippet that demonstrates how to work with UTF-8 encoding in a Python source file:
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.
In Python, how do I convert all of the items in a list to floats?
You can use a for loop and the float() function to convert each item in a list to a float.