How-to articles, tricks, and solutions about PANDAS
"Large data" workflows using pandas
Here is an example of a workflow for handling large data using the pandas library:
Change column type in pandas
In pandas, you can change the data type of a column using the astype() function.
Constructing pandas DataFrame from values in variables gives ValueError
Here is an example code snippet that demonstrates the issue:
Convert columns to string in Pandas
To convert all columns in a Pandas DataFrame to strings, you can use the following code snippet:
Convert floats to ints in Pandas?
To convert floats to integers in Pandas, you can use the astype() function.
Convert list of dictionaries to a pandas DataFrame
Here is an example of how to convert a list of dictionaries to a pandas DataFrame:
Convert pandas dataframe to NumPy array
In pandas, you can convert a DataFrame to a NumPy array by using the values attribute.
Convert Python dict into a dataframe
You can use the Pandas library to convert a Python dictionary into a dataframe.
Create a Pandas Dataframe by appending one row at a time
Here is an example of creating a Pandas DataFrame by appending one row at a time:
Delete a column from a Pandas DataFrame
You can delete a column from a Pandas DataFrame using the drop function.
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.
Filter pandas DataFrame by substring criteria
Here is an example of how you can filter a pandas DataFrame by substring criteria: