对于每个数据点,计算其与均值之差的平方。 计算以下数量
提到的日期是来自excel的数据,我将其导入软件中,然后计算出平均值。这就是我直到现在为止
import pandas as pd
ExcelSheet1 = pd.read_csv("C:\Sanja\E1StatsDATAsheet1.csv")
ExcelSheet2 = pd.read_csv("C:\Sanja\E1StatsDATAsheet2.csv")
print(ExcelSheet1)
print(ExcelSheet2)
print("Count for Sheet1 is:",ExcelSheet1.shape)
print("Count for Sheet2 is:",ExcelSheet2.shape)
Sum_ExcelSheet1 = ExcelSheet1.sum()
Sum_ExcelSheet2 = ExcelSheet2.sum()
print("Sum for Sheet1 is:",Sum_ExcelSheet1)
print("Sum for Sheet2 is:", Sum_ExcelSheet2)
import numpy
Mean_ExcelSheet1 = numpy.mean(ExcelSheet1)
Mean_ExcelSheet2 = numpy.mean(ExcelSheet2)
print("Mean for Sheet1 is:", Mean_ExcelSheet1)
print("Mean for Sheet2 is:", Mean_ExcelSheet2)
答案 0 :(得分:0)
很难给您“代码”,因为我不知道您具体需要什么,恐怕您必须学习如何做,幸运的是基本的python很简单。
要开始使用,read_csv应该已经用文件中的所有值填充了数组。您需要一个for循环来遍历每个元素,进行一些计算并存储所有结果。这是一些示例代码(假设您要获取1个csv文件中连续值的差异的平方根,如果要在文件之间进行差异,事情会变得更加复杂):
csv = [1,1,2,3,5,8,13,21,34]
ds = []
prev = None
for i in csv:
if prev == None:
prev = i
else:
diff = i - prev
sqr = diff * diff
ds.append(sqr)
prev = i
print (ds)
祝您在编码过程中一切顺利!