how to use dataframe in python
AI 回答
由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 导入pandas库
import pandas as pd
2. 创建DataFrame
data = {'列名1': [值1, 值2, ...], '列名2': [值1, 值2, ...]}
df = pd.DataFrame(data)
3. 查看DataFrame
print(df)
4. 访问数据
按列访问
print(df['列名'])
按行访问
print(df.iloc[行号])
5. 数据操作
添加列
df['新列名'] = 值
删除列
df.drop('列名', axis=1, inplace=True)
修改数据
df.at[行号, '列名'] = 新值
df.loc[行号, '列名'] = 新值
import pandas as pd
2. 创建DataFrame
data = {'列名1': [值1, 值2, ...], '列名2': [值1, 值2, ...]}
df = pd.DataFrame(data)
3. 查看DataFrame
print(df)
4. 访问数据
按列访问
print(df['列名'])
按行访问
print(df.iloc[行号])
5. 数据操作
添加列
df['新列名'] = 值
删除列
df.drop('列名', axis=1, inplace=True)
修改数据
df.at[行号, '列名'] = 新值
df.loc[行号, '列名'] = 新值
没有找到「how to use dataframe in python」相关的内容
建议:检查关键词是否有错别字,或换一个更常见的说法。