Python API
Overview
The main BipartitePandas API is split into eleven classes, four of which are base classes and one of which is for simulating bipartite data. It also has two modules for clustering: one for computing measures and one for grouping on measures. BipartitePandas is canonically imported using
import bipartitepandas as bpd
Main classes
bipartitepandas.BipartiteDataFrame
: Class to easily construct bipartite dataframes without explicitly specifying a formatbipartitepandas.BipartiteLong
: Class for bipartite networks in long formatbipartitepandas.BipartiteLongCollapsed
: Class for bipartite networks in collapsed long format (i.e. employment spells are collapsed into a single observation)bipartitepandas.BipartiteEventStudy
: Class for bipartite networks in event study formatbipartitepandas.BipartiteEventStudyCollapsed
: Class for bipartite networks in collapsed event study format (i.e. employment spells are collapsed into a single observation)bipartitepandas.BipartiteExtendedEventStudy
: Class for bipartite networks in extended event study formatbipartitepandas.BipartiteExtendedEventStudyCollapsed
: Class for bipartite networks in collapsed extended event study format (i.e. employment spells are collapsed into a single observation)bipartitepandas.SimBipartite
: Class for simulating bipartite networks
Base classes
bipartitepandas.BipartiteBase
: Base class for BipartiteLongBase and BipartiteEventStudyBase. All methods are usable by any class that inherits from BipartiteBase.bipartitepandas.BipartiteLongBase
: Base class for BipartiteLong and BipartiteLongCollapsed. All methods are usable by any class that inherits from BipartiteLongBase.bipartitepandas.BipartiteEventStudyBase
: Base class for BipartiteEventStudy and BipartiteEventStudyCollapsed. All methods are usable by any class that inherits from BipartiteEventStudyBase.bipartitepandas.BipartiteExtendedEventStudyBase
: Base class for BipartiteExtendedEventStudy and BipartiteExtendedEventStudyCollapsed. All methods are usable by any class that inherits from BipartiteExtendedEventStudyBase.
Clustering modules
bipartitepandas.measures
: Module for computing measuresbipartitepandas.grouping
: Module for grouping on measures
Classes and Methods
bipartitepandas.BipartiteDataFrame
|
Constructor class for easily constructing BipartitePandas dataframes without explicitly specifying a format. |
bipartitepandas.BipartiteBase
|
Base class for BipartitePandas, where BipartitePandas gives a bipartite network of firms and workers. |
|
Safe method for adding custom columns. |
|
Cluster data and assign a new column giving the cluster for each firm. |
|
Return copy of self. |
|
Run diagnostic and print diagnostic report. |
|
Drop labels along axis. |
|
Drop particular rows. |
|
Return dictionary linking properties to their value for a particular column. |
|
Log a message at the specified level. |
|
Toggle logger on or off. |
|
Merge two BipartiteBase objects. |
|
List firms with at least threshold many movers. |
|
Get the number of unique clusters. |
|
Get the number of unique firms. |
|
Number of unique ids in column. |
|
Get the number of unique workers. |
|
Return self merged with original column ids. |
|
Print properties associated with a particular column. |
|
Rename a column. |
|
Safe method for setting the properties of pre-existing custom columns. |
|
Sort frame columns (not in-place). |
|
Sort rows by i and t. |
|
Print summary statistics. |
|
Unique ids in column. |
bipartitepandas.BipartiteLongBase
|
Base class for BipartiteLong and BipartiteLongCollapsed, where BipartiteLong and BipartiteLongCollapsed give a bipartite network of firms and workers in long and collapsed long form, respectively. |
|
Clean data to make sure there are no NaN or duplicate observations, observations where workers leave a firm then return to it are removed, firms are connected by movers, and categorical ids are contiguous. |
|
Construct artificial time column(s) to enable conversion to (collapsed) event study format. |
|
Drop ids belonging to a given set of ids. |
|
Generate m column for data (m == 0 if stayer, m == 1 or 2 if mover). |
|
Only keep ids belonging to a given set of ids. |
|
Only keep particular rows. |
|
Return dataframe where column 1 ids have at least threshold_1 many observations and column 2 ids have at least threshold_2 many observations. |
|
Return dataframe where all firms have at least threshold many movers. |
|
List firms with at least threshold many moves. |
|
Return dataframe where all firms have at least threshold many moves. |
|
List column ids with at least threshold many observations. |
|
Return dataframe of column ids with at least threshold many observations. |
|
List firms with at least threshold many workers. |
|
Return dataframe of firms with at least threshold many workers. |
|
Return (collapsed) long form data reformatted into (collapsed) event study data. |
|
Return (collapsed) long form data reformatted into (collapsed) extended event study data. |
bipartitepandas.BipartiteLong
|
Class for bipartite networks of firms and workers in long form. |
|
Collapse long data at the worker-firm spell/match level (so each spell/match for a particular worker at a particular firm becomes one observation). |
|
Return Pandas dataframe of long format data with missing periods filled in as unemployed. |
|
Get NumPy array indicating whether the worker associated with each observation is a mover. |
bipartitepandas.BipartiteLongCollapsed
|
Class for bipartite networks of firms and workers in collapsed long form (i.e. |
|
Get NumPy array indicating whether the worker associated with each observation is a mover. |
|
Recollapse data by job spells (so each spell for a particular worker at a particular firm is one observation). |
|
Return collapsed long form data reformatted into collapsed permuted event study data. |
|
Return collapsed long data reformatted into long data, by assuming variables constant over spells. |
bipartitepandas.BipartiteEventStudyBase
|
Base class for BipartiteEventStudy and BipartiteEventStudyCollapsed, which give bipartite networks of firms and workers in event study and collapsed event study form, respectively. |
|
Clean data to make sure there are no NaN or duplicate observations, observations where workers leave a firm then return to it are removed, firms are connected by movers, and categorical ids are contiguous. |
|
Construct artificial time columns to enable conversion to (collapsed) long format. |
|
Run diagnostic and print diagnostic report. |
|
Drop ids belonging to a given set of ids. |
|
Generate m column for data (m == 0 if stayer, m == 1 if mover). |
|
Return (collapsed) event study data reformatted into cross section data. |
|
Only keep ids belonging to a given set of ids. |
|
Only keep particular rows. |
|
Return dataframe where column 1 ids have at least threshold_1 many observations and column 2 ids have at least threshold_2 many observations. |
|
Return dataframe where all firms have at least threshold many movers. |
|
List firms with at least threshold many moves. |
|
Return dataframe where all firms have at least threshold many moves. |
|
List column ids with at least threshold many observations. |
|
Return dataframe of column ids with at least threshold many observations. |
|
List firms with at least threshold many workers. |
|
Return dataframe of firms with at least threshold many workers. |
|
Return (collapsed) event study data reformatted into (collapsed) long form. |
bipartitepandas.BipartiteEventStudy
|
Class for bipartite networks of firms and workers in event study form. |
|
Collapse event study data at the worker-firm spell level (so each spell for a particular worker at a particular firm becomes one observation). |
|
Get NumPy array indicating whether the worker associated with each observation is a mover. |
bipartitepandas.BipartiteEventStudyCollapsed
|
Class for bipartite networks of firms and workers in collapsed event study form (i.e. |
|
Get NumPy array indicating whether the worker associated with each observation is a mover. |
|
Return collapsed event study data reformatted into event study data, by assuming variables constant over spells. |
bipartitepandas.BipartiteExtendedEventStudyBase
|
Base class for BipartiteExtendedEventStudy and BipartiteExtendedEventStudyCollapsed, which give bipartite networks of firms and workers in event study and collapsed event study form, respectively. |
|
Clean data to make sure there are no NaN or duplicate observations, observations where workers leave a firm then return to it are removed, firms are connected by movers, and categorical ids are contiguous. |
|
Construct artificial time columns to enable conversion to (collapsed) long format. |
|
Run diagnostic and print diagnostic report. |
|
Drop ids belonging to a given set of ids. |
|
Generate m column for data (m == 0 if stayer, m == 1 if mover). |
|
Only keep ids belonging to a given set of ids. |
|
Only keep particular rows. |
|
Return dataframe where column 1 ids have at least threshold_1 many observations and column 2 ids have at least threshold_2 many observations. |
|
Return dataframe where all firms have at least threshold many movers. |
|
List firms with at least threshold many moves. |
|
Return dataframe where all firms have at least threshold many moves. |
|
List column ids with at least threshold many observations. |
|
Return dataframe of column ids with at least threshold many observations. |
|
List firms with at least threshold many workers. |
|
Return dataframe of firms with at least threshold many workers. |
|
Return (collapsed) extended event study data reformatted into (collapsed) long form. |
bipartitepandas.BipartiteExtendedEventStudy
|
Class for bipartite networks of firms and workers in extended event study form. |
|
Collapse extended event study data at the worker-firm spell level (so each spell for a particular worker at a particular firm becomes one observation). |
|
Get NumPy array indicating whether the worker associated with each observation is a mover. |
bipartitepandas.BipartiteEventExtendedStudyCollapsed
bipartitepandas.SimBipartite
|
Class of SimBipartite, where SimBipartite simulates a bipartite network of firms and workers. |
|
Simulate panel data corresponding to the calibrated model. |
Modules and Methods
bipartitepandas.measures
|
Generate cdfs of compensation for firms. |
|
Generate compensation moments for firms. |
bipartitepandas.grouping
|
Compute KMeans groups for data. |
|
Compute quantile groups for data. |