DataFrame columns
时间: 2023-11-03 14:25:16 浏览: 94
Pandas库之DataFrame使用的学习笔记
A DataFrame is a two-dimensional data structure in which data is organized in rows and columns. The columns of a DataFrame represent the different variables or attributes of the data. Each column is a Series object, which is a one-dimensional labeled array that holds the data for that variable.
The following are some common operations that can be performed on DataFrame columns:
1. Accessing columns: You can access columns of a DataFrame using the column name as an index, or by using the dot notation.
2. Adding columns: You can add new columns to a DataFrame by specifying the name of the new column and the data to be added.
3. Renaming columns: You can rename the columns of a DataFrame using the rename() method.
4. Deleting columns: You can delete columns from a DataFrame using the drop() method.
5. Sorting columns: You can sort the columns of a DataFrame using the sort_values() method.
6. Applying functions to columns: You can apply functions to the columns of a DataFrame using the apply() method.
7. Filtering columns: You can filter columns of a DataFrame based on some condition using the loc[] method.
阅读全文