python pandas操作

参考:

https://blog.csdn.net/qq_41810188/article/details/108336378

https://blog.csdn.net/weixin_35752122/article/details/128871783

列出excel的sheet,读取不同sheet数据:

c 复制代码
sheet=pd.read_excel('nickname.xlsx',sheet_name=None)
print(list(sheet.keys()))
for j in sheet.keys():
    print(j)
    sheet=pd.read_excel('nickname.xlsx',sheet_name=None)

列出sheet的列名,读取某sheet中不同列的数据:

c 复制代码
import pandas as pd# 读取 Excel 文件
df = pd.read_excel('test.xlsx')

print(list(df.keys()))
# 获取第一列数据,并转化为数组
column1 = df['第一列的名称'].values
 
# 获取第二列数据,并转化为数组
column2 = df['第二列的名称'].values
 
# 输出第一列数据
print(column1)
 
# 输出第二列数据
print(column2)
相关推荐
databook20 小时前
Manim实现脉冲闪烁特效
后端·python·动效
程序设计实验室21 小时前
2025年了,在 Django 之外,Python Web 框架还能怎么选?
python
倔强青铜三1 天前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户2519162427111 天前
Python之语言特点
python
刘立军1 天前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机1 天前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机1 天前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i1 天前
django中的FBV 和 CBV
python·django
c8i1 天前
python中的闭包和装饰器
python
这里有鱼汤1 天前
小白必看:QMT里的miniQMT入门教程
后端·python