seems alright
This commit is contained in:
parent
ebe7bbb51d
commit
eac1bd0d13
58 changed files with 23125 additions and 153505 deletions
|
|
@ -268,6 +268,32 @@ fn extract_opt_datetime_iso(df: &DataFrame, name: &str) -> Result<Vec<Option<Str
|
|||
.collect())
|
||||
}
|
||||
|
||||
fn extract_str_list(df: &DataFrame, name: &str) -> Result<Vec<Vec<String>>> {
|
||||
let column = df
|
||||
.column(name)
|
||||
.with_context(|| format!("Missing column '{name}'"))?;
|
||||
let list = column
|
||||
.list()
|
||||
.with_context(|| format!("Column '{name}' is not a list column"))?;
|
||||
let mut out = Vec::with_capacity(list.len());
|
||||
for series_opt in list.into_iter() {
|
||||
let entries = match series_opt {
|
||||
Some(series) => {
|
||||
let strings = series.str().with_context(|| {
|
||||
format!("Column '{name}' list inner is not a string column")
|
||||
})?;
|
||||
strings
|
||||
.into_iter()
|
||||
.filter_map(|value| value.map(ToString::to_string))
|
||||
.collect()
|
||||
}
|
||||
None => Vec::new(),
|
||||
};
|
||||
out.push(entries);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -298,29 +324,3 @@ mod tests {
|
|||
assert!(!any_listing.listing_url.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_str_list(df: &DataFrame, name: &str) -> Result<Vec<Vec<String>>> {
|
||||
let column = df
|
||||
.column(name)
|
||||
.with_context(|| format!("Missing column '{name}'"))?;
|
||||
let list = column
|
||||
.list()
|
||||
.with_context(|| format!("Column '{name}' is not a list column"))?;
|
||||
let mut out = Vec::with_capacity(list.len());
|
||||
for series_opt in list.into_iter() {
|
||||
let entries = match series_opt {
|
||||
Some(series) => {
|
||||
let strings = series.str().with_context(|| {
|
||||
format!("Column '{name}' list inner is not a string column")
|
||||
})?;
|
||||
strings
|
||||
.into_iter()
|
||||
.filter_map(|value| value.map(ToString::to_string))
|
||||
.collect()
|
||||
}
|
||||
None => Vec::new(),
|
||||
};
|
||||
out.push(entries);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue