Tax-Calculator Records#

Tax-Calculator Records

taxcalc.records#

class taxcalc.records.Records(data=None, start_year=None, gfactors=None, weights=None, adjust_ratios=None, exact_calculations=False, weights_scale=0.01)[source]#

Records is a subclass of the abstract Data class, and therefore, inherits its methods (none of which are shown here).

Constructor for the tax-filing-unit Records class.

Parameters:
  • data (string or Pandas DataFrame or None) –

    string describes CSV file in which records data reside; DataFrame already contains records data; default value is None. NOTE: when using custom data, set this argument to a DataFrame. NOTE: to use your own data for a specific year with Tax-Calculator, be sure to read the documentation on creating your own data file and then construct a Records object like this: mydata = pd.read_csv(<mydata.csv>) myrec = Records(data=mydata, start_year=<mydata_year>,

    gfactors=None, weights=None)

    NOTE: data=None is allowed but the returned instance contains only

    the data variable information in the specified VARINFO file.

  • start_year (integer or None) – specifies calendar year of the input data;

  • None. (default value is) – Note that if specifying your own data (see above NOTE) as being a custom data set, be sure to explicitly set start_year to the custom data’s calendar year.

  • gfactors (GrowFactors class instance or None) – containing record data growth (or extrapolation) factors. default value is None.

  • weights (Pandas DataFrame or None) – DataFrame contains data weights; None creates empty weights DataFrame; default value is None NOTE: when using custom weights, set this argument to a DataFrame. NOTE: see weights_scale documentation below.

  • adjust_ratios (Pandas DataFrame or None) –

    DataFrame contains transposed/no-index adjustment ratios; None creates empty adjustment-ratios DataFrame; default value is None. NOTE: when using custom ratios, set this argument to a DataFrame. NOTE: if specifying a DataFrame, set adjust_ratios to my_df defined as:

    my_df = pd.read_csv(‘<my_ratios.csv>’, index_col=0).transpose()

  • exact_calculations (boolean) – specifies whether or not exact tax calculations are done without any smoothing of stair-step provisions in income tax law; default value is false.

  • weights_scale (float) – specifies the weights scaling factor used to convert contents of weights file into the s006 variable. PUF and CPS input data generated in the taxdata repository use a weights_scale of 0.01, while TMD input data generated in the tax-microdata repository use a 1.0 weights_scale value. default value is 0.01.

Raises:

ValueError: – if data is not the appropriate type. if taxpayer and spouse variables do not add up to filing-unit total. if dividends is less than qualified dividends. if gfactors is not None or a GrowFactors class instance. if start_year is not an integer. if files cannot be found.

Returns:

class instance

Return type:

Records

Notes

Use Records.cps_constructor() to get a Records object instantiated with CPS input data developed in the taxdata repository.

Use Records.puf_constructor() to get a Records object instantiated with PUF input data developed in the taxdata repository.

Use Records.tmd_constructor() to get a Records object instantiated with TMD input data developed in the tax-microdata repository.

_adjust(year)[source]#

Adjust value of PUF income variables to match SOI distributions Note: adjustment must leave variables as numpy.ndarray type

_extrapolate(year)[source]#

Apply to variables the grow factor values for specified calendar year.

_read_ratios(ratios)[source]#

Read Records PUF-related adjustment ratios using specified transposed/no-index DataFrame as ratios or create empty DataFrame if ratios is None.

static cps_constructor(data=None, gfactors=<taxcalc.growfactors.GrowFactors object>, exact_calculations=False)[source]#

Static method returns a Records object instantiated with CPS input data. This is a convenience method that eliminates the need to specify all the details of the CPS input data.

increment_year()[source]#

Add one to current year, and also does extrapolation, reweighting, adjusting for new current year.

static read_cps_data()[source]#

Return data in cps.csv.gz as a Pandas DataFrame.