You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# For the same "fy", "fp", we need to add to df_std_BS the following rows before the pivot_wider:
91
-
#
92
-
# new row: if Total Current Assets does not exist then it creates a new row whose val is Total Assets - Total Long Term Assets and standardized_balancesheet_label is Total Current Assets
93
-
#
94
-
# new row: if Other Current Assets does not exist then it creates a new row whose val is Total Current Assets - (Cash and Cash Equivalent + Marketable Securities, Current + Total Accounts Receivable + Total Inventory) and standardized_balancesheet_label is Other Current Assets
95
-
#
96
-
# new row: if Total Long Term Assets does not exist then it creates a new row whose val is val of Total Assets - val of Total Current Assets and standardized_balancesheet_label is Total Long Term Assets
97
-
#
98
-
# new row: if Other Non Current Assets does not exist then it creates a new row whose val is val of Total Long Term Assets - val of (Marketable Securities, Non Current + Property, Plant and Equipment+ Intangible Assets (excl. goodwill) + Goodwill) and standardized_balancesheet_label is Other Non Current Assets
99
-
#
100
-
# new row: if Total Current Liabilities does not exist then it creates a new row whose val is val of Liabilities - val of Liabilities, Non Current and standardized_balancesheet_label is Total Current Liabilities
101
-
#
102
-
# new row: if Other Current Liabilities does not exist then it creates a new row whose val is val of Total Current Liabilities - val of (Accounts Payable, Current + Taxes Payable, Current + Commercial Paper + Long Term Debt, Current Maturities + Operating Lease, Liability, Current + Finance Lease, Liability, Current) and standardized_balancesheet_label is Other Current Liabilities
103
-
#
104
-
# new row: if Total Long Term Liabilities does not exist then it creates a new row whose val is val of Total Liabilities - val of Total Current Liabilities and standardized_balancesheet_label is Total Long Term Liabilities
105
-
#
106
-
#
107
-
# new row: if Other Long Term Liabilities does not exist then it creates a new row whose val is val of Total Long Term Liabilities - val of (Long Term Debts - Operating Lease, Liability, Non Current + Finance Lease, Liability, Non Current and standardized_balancesheet_label is Other Long Term Liabilities
108
-
#
109
-
# new row: if Other Stockholders Equity does not exist then it creates a new row whose val is val of Total Company Stockholders Equity - val of (Common Stock + Additional Paid in Capital + Preferred Stock + Retained Earnings + Accumulated other comprehensive income (loss)) and standardized_balancesheet_label is Other Stockholders Equity
90
+
# 01 - Data cleaning ------------------------------------------------------
91
+
# This code filters rows in df_std_BS based on the presence of "/A" in the 'form' column, ensuring rows with "/A" are retained if any in their group have it. It then selects relevant columns, arranges by descending 'end' date, and for each unique 'val', keeps the row with the most recent 'end' date.
110
92
111
-
112
-
# Filter out records not associated with standardized_balancesheet to create the mapping with df_Facts
# 03 - Pivot df_std_BS in a dataframe format -----------------------------------
162
+
# Transforms your data from a long format with multiple rows per observation to a wide format where each observation is represented by a single row with columns corresponding to different labels
141
163
142
-
# 02 - Pivot columns of df_std_BS ---------------------------------------------------
143
164
# Build df_std_BS dataframe pivoting the standardized labels into columns
144
-
df_std_BS_pivoted<-df_std_BS_cleaned %>%
145
-
pivot_wider(
165
+
df_std_BS<-df_std_BS %>%
166
+
# Pivot the data using standardized_balancesheet_label as column names
167
+
pivot_wider(
146
168
names_from=standardized_balancesheet_label,
147
169
values_from=val
148
170
) %>%
171
+
# Arrange the dataframe in descending order based on the 'end' column
149
172
arrange(desc(end))
150
173
151
-
return(df_std_BS_pivoted)
174
+
# >>>---- CONTINUE HERE - CHECK RESULTS ----<<<<<
175
+
# There are instances in which the filing includes comparison with previous reporting period. In such instances additional details of the previous reporting period are included. The following code merge the row with referring to the same period end where these additional details are provided.
# For the same "fy", "fp", we need to add to df_std_BS the following rows before the pivot_wider:
180
+
#
181
+
# new row: if Total Current Assets does not exist then it creates a new row whose val is Total Assets - Total Long Term Assets and standardized_balancesheet_label is Total Current Assets
182
+
#
183
+
# new row: if Other Current Assets does not exist then it creates a new row whose val is Total Current Assets - (Cash and Cash Equivalent + Marketable Securities, Current + Total Accounts Receivable + Total Inventory) and standardized_balancesheet_label is Other Current Assets
184
+
#
185
+
# new row: if Total Long Term Assets does not exist then it creates a new row whose val is val of Total Assets - val of Total Current Assets and standardized_balancesheet_label is Total Long Term Assets
186
+
#
187
+
# new row: if Other Non Current Assets does not exist then it creates a new row whose val is val of Total Long Term Assets - val of (Marketable Securities, Non Current + Property, Plant and Equipment+ Intangible Assets (excl. goodwill) + Goodwill) and standardized_balancesheet_label is Other Non Current Assets
188
+
#
189
+
# new row: if Total Current Liabilities does not exist then it creates a new row whose val is val of Liabilities - val of Liabilities, Non Current and standardized_balancesheet_label is Total Current Liabilities
190
+
#
191
+
# new row: if Other Current Liabilities does not exist then it creates a new row whose val is val of Total Current Liabilities - val of (Accounts Payable, Current + Taxes Payable, Current + Commercial Paper + Long Term Debt, Current Maturities + Operating Lease, Liability, Current + Finance Lease, Liability, Current) and standardized_balancesheet_label is Other Current Liabilities
192
+
#
193
+
# new row: if Total Long Term Liabilities does not exist then it creates a new row whose val is val of Total Liabilities - val of Total Current Liabilities and standardized_balancesheet_label is Total Long Term Liabilities
194
+
#
195
+
#
196
+
# new row: if Other Long Term Liabilities does not exist then it creates a new row whose val is val of Total Long Term Liabilities - val of (Long Term Debts - Operating Lease, Liability, Non Current + Finance Lease, Liability, Non Current and standardized_balancesheet_label is Other Long Term Liabilities
197
+
#
198
+
# new row: if Other Stockholders Equity does not exist then it creates a new row whose val is val of Total Company Stockholders Equity - val of (Common Stock + Additional Paid in Capital + Preferred Stock + Retained Earnings + Accumulated other comprehensive income (loss)) and standardized_balancesheet_label is Other Stockholders Equity
0 commit comments