Code Snippets
Search our repository of helpful code snippets for data processing and analysis (using Python/Pandas and SQL).
Complete list of references
Pandas
- Add new column to Pandas dataframe with default value
- Create a pivot table from a Pandas dataframe
- Convert column in Pandas dataframe to a list
- Create a new column in Pandas dataframe
- Create Pandas dataframe with random numbers
- Count the frequency a value occurs in Pandas dataframe
- Count distinct in Pandas aggregation
- Concatenate Pandas dataframes (like a union function in SQL)
- Change the order of columns in Pandas dataframe
- Dynamically update a plot in iPython notebook
- Dropping rows/columns from a Pandas dataframe
- Drop duplicate rows in Pandas based on column value
- Extract month and year from column in Pandas, create new column
- Find and replace characters in Pandas dataframe columns
- Get the row count and column count from a Pandas dataframe
- Get the mean and median from a Pandas column in Python
- Iterate over rows in a dataframe in Pandas
- Merge two dataframes together in Pandas
- Pandas rolling mean in dataframe
- Rename columns in a Pandas dataframe
- Remove duplicate columns by name in Pandas
- Remove NaN values from a Pandas series
- Replace all NaN values with 0's in a column of Pandas dataframe
- Read data from CSV into Pandas. Output data from Pandas to CSV
- Return the number of columns in a Pandas dataframe
- Sort a dataframe in Pandas based on multiple columns
- Select Pandas dataframe rows between two dates
- Select rows from a Pandas DataFrame based on values in a column
- SearchInput pandas column with string contains and does not contain
Python
- Access the index of a Python for loop (enumerate)
- Break a long line into multiple lines in Python
- Convert strings to lower and uppercase in Python
- Create a scatter plot in Python with Seaborn
- Check whether a Python string contains another string
- Check if a list is empty in Python
- Create a scatter plot in Python with Matplotlib
- Create a bar chart in Python with Matplotlib
- Create and run a function in Python
- Convert to number to float, int, and string in Python
- Convert a list of Python dictionaries to a Pandas dataframe
- Concatenate two arrays (lists) in Python
- Generate current time in Python
- Generate a for loop in Python
- Iterate over dictionaries in Python
- Introduction to forecasting with FB Prophet
- Introduction to Linear Regression using Python
- Importing data from MongoDB into Python (Pandas)
- If and else statements in Python
- Open a browser URL using Python
- Slice a string in python (right, left, mid equivalents)
- Sort a Python dictionary by value or key
- Slice notation in Python
- Time delay in Python script (sleep)
- Web scraping with Python using Beautiful Soup