该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import pandas as pd
import numpy as np
import math
import csv
if __name__ == "__main__":
path = 'F:\\Desktop\\3\\python\\T1\\1.csv'
# pandas读入
data = pd.read_csv(path)
print(data)
# 将dataframe转换为list
x=data['X'].values.tolist()
y=data['Y'].values.tolist()
#自动求相邻的差,并写入列表
def cha(ls):
m=[]
for ix in ls:
if ix==ls[0]:
a=ls[0]
continue
else:
b=ix-a
a=ix
m.append(b)
return m
xx=cha(x)
yy=cha(y)
xxx=np.array(xx)
yyy=np.array(yy)
t=yyy/xxx
#先转化为弧度,再转化为角度,所有的角度形成一个列表
at=[math.atan(i) for i in t]
angle=[math.degrees(i) for i in at]
#将结果增加一行到ANGLE.csv中
with open("F:\\Desktop\\3\\python\\T1.csv", "a", newline='', encoding='utf-8') as file:
writer = csv.writer(file ,delimiter=',')
writer.writerow(angle)