StringFormatter =============== .. cpp:class:: pandas::StringFormatter pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use StringFormatter StringFormatter obj; // ... operations ... Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``StringFormatter(const DisplayConfig& opts, size_t line_width)`` - pd_string_formatter.h:42 - I/O --- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``std::string to_string(strcols_t strcols, bool truncated_v, bool truncated_h, size_t tr_row_num, size_t tr_col_num, size_t n_header_rows, size_t n_index_cols, std::string_view info_line = "") const`` - std::string - pd_string_formatter.h:57 - :ref:`View ` Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``size_t line_width() const`` - size_t - pd_string_formatter.h:46 - * - ``const DisplayConfig& options() const`` - const DisplayConfig& - pd_string_formatter.h:45 - Internal Methods ---------------- *8 internal methods (prefixed with underscore)* Code Examples ------------- The following examples are extracted from the test suite. .. _example-stringformatter-to_string-0: .. dropdown:: to_string (pd_test_1_all.cpp:2693) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 2683 :emphasize-lines: 11 pandas::PeriodArray arr_m(std::vector{ "2020-01", "NaT", "2025-06" }, "M"); // Year auto years = arr_m.year(); auto y0 = years[0]; if (!y0.has_value() || y0.value() != 2020) { std::cout << " [FAIL] : year[0] should be 2020, got " << (y0.has_value() ? std::to_string(y0.value()) : "NA") << std::endl; throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[0]"); } auto y1 = years[1]; if (y1.has_value()) { std::cout << " [FAIL] : year[1] should be NA (NaT)" << std::endl; throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[1] should be NA"); } auto y2 = years[2];