Signature Description Parameters

void
rename_column (const char *from, const char *to);
        
It renames column named from to to. If column from does not exists, it throws an exception
from: Current column name.
to: New column name
static void test_rename_column()  {

    std::cout << "\nTesting rename_column() ..." << std::endl;

    std::vector<unsigned long>  idx =
        { 123450, 123451, 123452, 123453, 123454, 123455, 123456, 123457, 123458, 123459, 123460, 123461, 123462, 123466 };
    std::vector<double> d1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
    std::vector<double> d2 = { 8, 9, 10, 11, 12, 13, 14, 20, 22, 23, 30, 31, 32, 1.89};
    std::vector<double> d3 = { 15, 16, 17, 18, 19, 20, 21, 0.34, 1.56, 0.34, 2.3, 0.1, 0.89, 0.45 };
    std::vector<int>    i1 = { 22, 23, 24, 25, 99, 100, 101, 3, 2 };
    MyDataFrame         df;

    df.load_data(std::move(idx),
                 std::make_pair("col_1", d1),
                 std::make_pair("col_2", d2),
                 std::make_pair("col_3", d3),
                 std::make_pair("col_4", i1));

    std::cout << "Before rename" << std::endl;
    df.write<std::ostream, double, int>(std::cout);
    df.rename_column("col_2", "renamed_column");
    std::cout << "After rename" << std::endl;
    df.write<std::ostream, double, int>(std::cout);
}
C++ DataFrame