如何使用python将Excel数据读取到数组中 [英] How to get read excel data into an array with python

查看:2636
本文介绍了如何使用python将Excel数据读取到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我从事的实验室中,我们处理了96孔板读数器产生的许多数据.我正在尝试编写一个脚本,该脚本将执行一些计算并使用matplotlib输出条形图.

In the lab that I work in, we process a lot of data produced by a 96 well plate reader. I'm trying to write a script that will perform a few calculations and output a bar graph using matplotlib.

问题在于印版读取器将数据输出到.xlsx文件中.我了解某些模块(例如pandas)具有read_excel函数,您能解释一下我应该如何读取excel文件并将其放入数据框吗?

The problem is that the plate reader outputs data into a .xlsx file. I understand that some modules like pandas have a read_excel function, can you explain how I should go about reading the excel file and putting it into a dataframe?

谢谢

24孔板的数据样本(为简单起见):

Data sample of a 24 well plate (for simplicity):

0.0868  0.0910  0.0912  0.0929  0.1082  0.1350
0.0466  0.0499  0.0367  0.0445  0.0480  0.0615
0.6998  0.8476  0.9605  0.0429  1.1092  0.0644
0.0970  0.0931  0.1090  0.1002  0.1265  0.1455

推荐答案

这些任务在如今的熊猫市中非常容易.

This task is super easy in Pandas these days.

import pandas as pd

df = pd.read_excel('file_name_here.xlsx', sheet_name='Sheet1')

df = pd.read_csv('file_name_here.csv')

这将返回一个pandas.DataFrame对象,该对象对于按列,行,整个df或带有迭代的单个项目执行操作非常强大.更不用说以不同的方式进行切片了.

This returns a pandas.DataFrame object which is very powerful for performing operations by column, row, over an entire df, or over individual items with iterrows. Not to mention slicing in different ways.

这篇关于如何使用python将Excel数据读取到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆