pandas.DataFrame.columns — pandas 3.0.0.dev0+2103.g41968a550a documentation (original) (raw)
- API reference
- DataFrame
- pandas.DataFrame.columns
DataFrame.columns#
The column labels of the DataFrame.
This property holds the column names as a pandas Index
object. It provides an immutable sequence of column labels that can be used for data selection, renaming, and alignment in DataFrame operations.
Returns:
pandas.Index
The column labels of the DataFrame.
Examples
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) df A B 0 1 3 1 2 4 df.columns Index(['A', 'B'], dtype='object')