我有一个简单的数据帧:
df = [ {'col1' : 'A', 'col2': 'B', 'col3': 'C', 'col4':'0'},
{'col1' : 'M', 'col2': '0', 'col3': 'M', 'col4':'0'},
{'col1' : 'B', 'col2': 'B', 'col3': '0', 'col4':'B'},
{'col1' : 'X', 'col2': '0', 'col3': 'Y', 'col4':'0'}
]
df = pd.DataFrame(df)
df = df[['col1', 'col2', 'col3', 'col4']]
df
Run Code Online (Sandbox Code Playgroud)
看起来像这样:
| col1 | col2 | col3 | col4 |
|------|------|------|------|
| A | B | C | 0 |
| M | 0 | M | 0 |
| B | B …Run Code Online (Sandbox Code Playgroud)