Python Pandas pivot()

Syntax pandas.pivot(data, index=None, columns=None, values=None) Return Value: The return value for the pivot() function is a reshaped DataFrame organized by index/column values. Background Direct quote from the Pandas Documentation website: This function does not support data aggregation. If there are multiple values, they will result in a Multi-Index in the columns. This article delves into … Read more

Python Pandas melt()

Syntax pandas.melt(frame, id_vars=None, value_vars=None, var_name=None, value_name=’value’, col_level=None, ignore_index=True) Return Value The return value for the melt() function is an unpivoted DataFrame. Background Direct quote from the Pandas Documentation website: “This function massages a DataFrame into a format where one or more columns are identifier variables (id_vars). While all other columns are considered measured variables (value_vars), … Read more

BeatifulSoup Find *

Preparation This article assumes you have the following libraries installed: Requests Beautifulsoup and a basic understanding of: HTML CSS Python Add the following code to the top of each code snippet. This snippet will allow the code in this article to run error-free. Beautifulsoup Find by ID If the HTML code contains one or more … Read more

Python Excel – Styling Your Worksheets

Part 6 in Working with Excel focuses on styling. Impress your customers by styling the Worksheet to match their brand by: adding in their unique logo, using their color scheme, using their preferred font style, formatting the Worksheet using their preferred report style. Taking the time to do this makes you stand above the crowd. … Read more

Python Excel – Sum, Average, Max, and Date Formulas

Part 5 in the Working with Excel series focuses on formulas.   Background After completing Part 4 of this series, you should be comfortable using Python and openpyxl to: add worksheets rename worksheets reorder worksheets delete Worksheets The j-greats.xlsx file should exist on your system.  If you do not have this particular file, click here … Read more

Python Excel – Basic Worksheet Operations

Part 4 in the Working with Excel series focuses on Worksheet(s) manipulation.   Background After completing Part 3 of this series, you should be comfortable using Python and openpyxl to: append row(s), modify data, insert column(s), delete row(s) and column(s) The j-greats.xlsx file should exist on your system. If you do not have this particular … Read more

Python Excel – Manipulating Worksheet Data

Building on the skill(s) you learned earlier, Part 3 centers around manipulating the data. This skill is another must-have if you are interested in pursuing a career as a Data Scientist. Background After completing Part 2 of this series, you should be comfortable using Python to: access a single row/column value, access a range of … Read more

Python Get Values from a Nested Dictionary

A Python nested dictionary is a dictionary with another dictionary or dictionaries nested within (dictionary of dictionaries or collection of collections). Nested dictionaries are one way to represent structured data (similar to a database table(s) relationship). An analogy for this concept is the Russian Nesting Dolls.   Our article focuses on various ways to retrieve … Read more

Python Convert List Pairs to a Dictionary

The Python dictionary is a structure used to store data. This data type is appropriate when the data needs to contain labels (unique keys) associated with a value (key:value). Python lists are not able to handle this format. The list(s) will require conversion to a dictionary format (key:value). There are various ways to accomplish this … Read more

Python Dictionary: How to Create, Add, Replace, Retrieve, Remove

Python defines the dictionary data type as an unordered collection that contains key:value pairs. The key:value pairs (separated by commas) are wrapped inside curly braces ({}). Β  Each key inside the dictionary must be unique and immutable. Dictionary keys can be one of the following data types: integer, string, or tuple. Dictionary keys can not … Read more