Techno Blender
Digitally Yours.
Browsing Tag

Ariza

Memoizing DataFrame Functions. Using Hashable DataFrames and Message… | by Christopher Ariza | Mar, 2023

Using Hashable DataFrames and Message Digests to Optimize Repeated CalculationsPhoto by AuthorA well-known technique for improving the run-time performance of a software system (in Python or any language) is function memoization. Memoization is a type of caching applied to a single function. If a function is called multiple times with the same arguments, repeating the calculation can be avoided by storing the results in a mapping (or on disk), keyed by the arguments. Upon subsequent calls, if the arguments are found, the…

One Fill Value Is Not Enough: Preserving Columnar Types When Reindexing DataFrames | by Christopher Ariza | Jul, 2022

When working with DataFrames, reindexing is common. When a DataFrame is reindexed, an old index (and its associated values) is conformed to a new index, potentially reordering, contracting, or expanding the rows or columns. When a reindex expands a DataFrame, new values are needed to fill the newly created rows or columns: these are “fill values.”When reindexing with Pandas, only a single value, via the fill_value parameter, is permitted. If that fill_value is a type incompatible with the type of one or more columns, the…