python get all columns with lists code example
Example 1: python return column names of pandas dataframe
your_dataframe.columns
list(your_dataframe.columns)
Example 2: get column names
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;
}