Update rwd_code_for_opt.py
Browse files- rwd_code_for_opt.py +17 -0
rwd_code_for_opt.py
CHANGED
|
@@ -27,3 +27,20 @@ def json_report_date_insertion(json_data, df):
|
|
| 27 |
attribute_details = attribute['attribute_details']
|
| 28 |
attribute['attribute_details'] = report_date_check(attribute_details, df)
|
| 29 |
return json_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
attribute_details = attribute['attribute_details']
|
| 28 |
attribute['attribute_details'] = report_date_check(attribute_details, df)
|
| 29 |
return json_data
|
| 30 |
+
|
| 31 |
+
def dicts_to_dataframe(list_of_dicts):
|
| 32 |
+
# Initialize an empty DataFrame
|
| 33 |
+
df = pd.DataFrame()
|
| 34 |
+
|
| 35 |
+
# Iterate through each dictionary in the list
|
| 36 |
+
for d in list_of_dicts:
|
| 37 |
+
# Convert each dictionary into a DataFrame
|
| 38 |
+
temp_df = pd.DataFrame([d])
|
| 39 |
+
|
| 40 |
+
# Concatenate the temporary DataFrame with the main DataFrame
|
| 41 |
+
df = pd.concat([df, temp_df], ignore_index=True)
|
| 42 |
+
|
| 43 |
+
# Fill missing values with empty strings
|
| 44 |
+
df = df.fillna('')
|
| 45 |
+
|
| 46 |
+
return df
|