df.columns[:-1]
时间: 2024-05-24 15:10:20 浏览: 71
括号生成(dfs)1
This code returns all the column names except the last one in a pandas dataframe 'df'.
Explanation:
- 'df.columns' returns a pandas Index object containing all the column names in the dataframe 'df'.
- '[:-1]' is a slice notation that returns all the elements in the Index object except the last one.
阅读全文