随笔分类 -  Python

Python
摘要:QFileDialog有四项功能 1.打开文件夹 getExistingDirectory() def openfolder(self): self.folder = QFileDialog.getExistingDirectory(self) print(self.folder) 2.打开特定文件 阅读全文
posted @ 2022-10-12 13:42 华小电 阅读(938) 评论(0) 推荐(0)
摘要:在Qt Designer中先建立UI,转成py文件,文件名为:plot_ui.py # -*- coding: utf-8 -*- ################################################################################ ## 阅读全文
posted @ 2022-10-10 10:17 华小电 阅读(291) 评论(0) 推荐(0)
摘要:from PySide6.QtWidgets import QApplication, QMainWindow,QWidget import pyqtgraph as pg import sys from PySide6 import QtCore,QtWidgets import numpy as 阅读全文
posted @ 2022-10-09 18:21 华小电 阅读(240) 评论(0) 推荐(0)
摘要:示例1 from PySide6.QtWidgets import QWidget,QApplication from PySide6 import QtWidgets ,QtCore import pyqtgraph as pg import sys import numpy as np clas 阅读全文
posted @ 2022-10-09 17:06 华小电 阅读(156) 评论(0) 推荐(0)
摘要:DataFrame 提取一行后 就变成Series,DF的列(columns) 就变成Series的索引(index ),再保存到csv文件,格式就乱了 处理办法:将Series的value提取出来,变成list格式,用append()将所有提起的数据放在一起,再转成DataFrame格式,再添加原 阅读全文
posted @ 2022-07-04 09:52 华小电 阅读(633) 评论(0) 推荐(0)
摘要:原数据中第2,4,6。。。列没有用,需要删除 filename = 'Pnt_210101000000_page27' df = pd.read_csv(name+'.csv') # 删除第一行 单位符号 #df.drop(index=0, inplace = True) # 区power 列 #p 阅读全文
posted @ 2022-07-03 17:28 华小电 阅读(408) 评论(0) 推荐(0)
摘要:在使用set_xticklabels时,报错 UserWarning: FixedFormatter should only be used together with FixedLocator 究其原因,原来set_xticks()和set_xticklabels()需要同时使用,缺一不可 阅读全文
posted @ 2022-05-15 10:36 华小电 阅读(1284) 评论(0) 推荐(1)
摘要:batch_size , seq ,num_layers = 2,3,2 input_size , hidden_size = 2,3 input = torch.randn(batch_size, seq, input_size) h_0 = torch.zeros(num_layers,batc 阅读全文
posted @ 2022-04-27 11:30 华小电 阅读(59) 评论(0) 推荐(0)
摘要:rnn = nn.RNN(input_size=4,hidden_size=3,num_layers=2,batch_first=True, bidirectional = True) input = torch.randn(1,5,4) output , h_n = rnn(input) prin 阅读全文
posted @ 2022-04-25 09:04 华小电 阅读(327) 评论(0) 推荐(0)
摘要:batch_first – If True, then the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Note that this does n 阅读全文
posted @ 2022-04-25 08:49 华小电 阅读(693) 评论(0) 推荐(0)
摘要:# Define LSTM class Lstm(nn.Module): def __init__(self, input_size, hidden_size=2, output_size=1, num_layers=1): super().__init__() self.layer1 = nn.L 阅读全文
posted @ 2022-04-07 20:18 华小电 阅读(47) 评论(0) 推荐(0)
摘要:x=np.arange(1,100) y = np.sin(0.1*x) def D_1(x,y): n = len(x) d = np.zeros(n) d[0] = (y[1]-y[0])/(x[1]-x[0]) d[n-1] = (y[n-1]-y[n-2])/(x[n-1]-x[n-2]) 阅读全文
posted @ 2022-03-29 16:10 华小电 阅读(467) 评论(0) 推荐(0)
摘要:x = [1,2,3] y1 = np.array([4,5,6]) y2 = np.array([5,6,7]) y3 = np.array([7,6,5]) width = 0.2 Sum = y1+y2+y3 per = 100*y2/Sum #添加在中间,旋转90度 def add_mid( 阅读全文
posted @ 2022-03-29 09:13 华小电 阅读(441) 评论(0) 推荐(0)
摘要:```python def firstorder(T,K,t,In): # T 时间常数 # K 增益 Out = np.zeros(len(In)) for i in range(1,len(t)): dt = t[i]-t[i-1] s = T/dt Out[i] = K*In[i]/(s+1) 阅读全文
posted @ 2022-03-24 13:52 华小电 阅读(933) 评论(0) 推荐(0)
摘要:x = np.arange(0,101) wn = np.random.rand(101) y1 = -1+0.02*x+0.1*wn y2 = np.sin(0.5*x) y3 = 0.0001*x**2-0.03*x+1 y4 = 0.8*np.cos(x) fig,ax1 = plt.subp 阅读全文
posted @ 2022-03-24 11:17 华小电 阅读(242) 评论(0) 推荐(0)
摘要:import numpy as np import statsmodels.api as sm from gekko import GEKKO # Data x0 = np.array([4,5,2,3,-1,1,6,7]) x1 = np.array([3,2,3,4, 3,5,2,6]) y = 阅读全文
posted @ 2022-03-17 14:16 华小电 阅读(778) 评论(0) 推荐(0)
摘要:import numpy as np from scipy.stats import linregress import statsmodels.api as sm import matplotlib.pyplot as plt from gekko import GEKKO # Data x = 阅读全文
posted @ 2022-03-17 14:15 华小电 阅读(762) 评论(0) 推荐(0)
摘要:x = np.random.random(10) y = np.random.random(10) note = np.arange(1,11) plt.scatter(x,y,marker = 'o', c = 'r') plt.title('在数据上添加标注',fontproperties='M 阅读全文
posted @ 2021-12-11 21:57 华小电 阅读(300) 评论(0) 推荐(0)
摘要:from matplotlib import font_manager # fname中选择一个你本机查询出来的字体 若没有中文字体则需要你本人手动安装 font = font_manager.FontProperties(fname="/usr/share/fonts/wenquan/wenqua 阅读全文
posted @ 2021-12-11 21:13 华小电 阅读(617) 评论(0) 推荐(0)
摘要:使用openpyxl保存数据到Excel文件报错:BadZipFile: File is not a zip file 如果保存的文件不存在,直接用pd.ExcelWriter 如果保存的文件已存在,用openpyxl.load_workbook加载已有的文件, 再使用pd.ExcelWriter 阅读全文
posted @ 2021-11-21 14:03 华小电 阅读(1522) 评论(0) 推荐(0)