pub fn format_strings(
vec_col: &[&str],
lower_column_width: usize,
upper_column_width: usize,
sigfig: i64,
preserve_scientific: bool,
max_decimal_width: usize,
) -> Vec<String>
Expand description
Formats a column of strings with consistent width and significant figures.
This is the main formatting function that processes an entire column of data. It applies significant figure formatting to numeric values, handles NA values, and ensures all strings fit within the specified width constraints.
§Arguments
vec_col
- Vector of string references representing the column datalower_column_width
- Minimum column widthupper_column_width
- Maximum column widthsigfig
- Number of significant figures for numeric valuespreserve_scientific
- Whether to preserve scientific notationmax_decimal_width
- Maximum width for decimal places
§Returns
A vector of formatted strings with consistent width and formatting.
§Examples
use tidy_viewer_core::datatype::format_strings;
let data = vec!["123.456", "NA", "-42.1", "hello"];
let formatted = format_strings(&data, 2, 20, 3, false, 13);
// All formatted strings will have consistent width and formatting
assert_eq!(formatted.len(), 4);