dfatafranme show column label code example

Example 1: get column number in dataframe pandas

# PANDAS: get column number from colomn name
dataframe.columns.get_loc("<col_name>")

Example 2: get column names as list

public static List<String> getColumnNames(){


        List<String> columnList = new ArrayList<>();
        try {
            ResultSetMetaData rsMetaData = rs.getMetaData();
            for (int colNum = 1; colNum < getColumnCount()  ; colNum++) {
                columnList.add(rsMetaData.getColumnLabel(colNum));
            }
        } catch (SQLException e) {
       System.out.println("ERROR WHILE GETTING COLUMN NAMES "+ e.getMessage());
        }

        return columnList;
    }