MCPcopy Create free account
hub / github.com/Pometry/Raphtory / create_row

Function create_row

raphtory/src/python/utils/export.rs:137–194  ·  view source on GitHub ↗
(
    convert_datetime: bool,
    explode: bool,
    column_names: &Vec<String>,
    properties_map: HashMap<String, Prop>,
    prop_time_dict: HashMap<i64, HashMap<String, Prop>>,
    row_header: Vec

Source from the content-addressed store, hash-verified

135}
136
137pub(crate) fn create_row(
138 convert_datetime: bool,
139 explode: bool,
140 column_names: &Vec<String>,
141 properties_map: HashMap<String, Prop>,
142 prop_time_dict: HashMap<i64, HashMap<String, Prop>>,
143 row_header: Vec<Prop>,
144 start_point: usize,
145 history: Vec<i64>,
146) -> Vec<Vec<Prop>> {
147 if explode {
148 let new_rows: Vec<Vec<Prop>> = prop_time_dict
149 .par_iter()
150 .map(|(time, item_dict)| {
151 let mut row: Vec<Prop> = row_header.clone();
152 for prop_name in &column_names[start_point..(column_names.len() - 1)] {
153 if let Some(prop_val) = properties_map.get(prop_name) {
154 row.push(prop_val.clone());
155 } else if let Some(prop_val) = item_dict.get(prop_name) {
156 row.push(prop_val.clone());
157 } else {
158 row.push(Prop::from(""));
159 }
160 }
161
162 if convert_datetime {
163 row.push(Prop::DTime(time.dt().unwrap()));
164 } else {
165 row.push(Prop::from(*time));
166 }
167
168 row
169 })
170 .collect();
171 new_rows
172 } else {
173 let mut row: Vec<Prop> = row_header.clone();
174 // Flatten properties into the row
175 for prop_name in &column_names[start_point..(column_names.len() - 1)] {
176 // Skip the first column (name)
177 let blank_prop = Prop::from("");
178 let prop_value = properties_map.get(prop_name).unwrap_or(&blank_prop);
179 row.push(prop_value.clone()); // Append property value as string
180 }
181
182 if convert_datetime {
183 let update_list = history
184 .iter()
185 .map(|val| Prop::DTime(val.dt().unwrap()))
186 .collect_vec();
187 row.push(Prop::from(update_list));
188 } else {
189 let update_list = Prop::from(history.iter().map(|&val| Prop::from(val)).collect_vec());
190 row.push(update_list);
191 }
192 vec![row]
193 }
194}

Callers 2

to_dfMethod · 0.85
to_dfMethod · 0.85

Calls 11

unwrapMethod · 0.80
collect_vecMethod · 0.80
collectMethod · 0.45
mapMethod · 0.45
par_iterMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45
getMethod · 0.45
pushMethod · 0.45
dtMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected