shift_fundamental

Description

Shift the financial unpivot CM by n quarters.

---------------------------
fiscal  pit         value
---------------------------
202001  2020-04-15  a
202002  2020-07-15  b
202003  2020-10-15  c
202003  2020-11-15  d
202003  2021-02-15  e
202004  2021-01-15  f
202102  2022-07-15  g
202103  2022-10-15  h
---------------------------

shift 1 quarter
↓
---------------------------
fiscal  pit         value
---------------------------
202002  2020-07-15  a
202003  2020-10-15  b
202004  2021-01-15  d
202004  2021-02-15  e
202103  2022-10-15  g
---------------------------

Note

  • On '2021-01-15' previous quarter value was 'd'(The value on 202003; 2020-11-15) Then when '2021-02-15' previous quarter value becomes 'e'

  • Because there is no 202101 pit and value, value 'f' is dropped.

Parameters

  • df (pandas.DataFrame): financial unpivot CM

  • periods (int > 0)

  • fiscal (str; ["quarter", "annual"]) : Default - 'quarter'

Returns

  • pandas.DataFrame

Example

# df_a is financial unpivot cm
df_a = FinHelper.shift_fundamental(df_a, periods=1)

Last updated