随笔分类 -  Python

Python
摘要:df.to_sql参数介绍: name:SQL表的名称。 con:sqlalchemy.engine.Engine或sqlite3.Connection 使用SQLAlchemy可以使用该库支持的任何数据库。为sqlite3.Connection对象提供了旧版支持。 if_exists:{'fail 阅读全文
posted @ 2022-11-23 20:50 华小电 阅读(3767) 评论(0) 推荐(0) 编辑
摘要:1 一行 For 循环 #For循环在一行mylist = [200, 300, 400, 500] #正常方式 result = [] for x in mylist: if x > 250: result.append(x) print(result) # [300, 400, 500] #一行 阅读全文
posted @ 2022-11-20 16:48 华小电 阅读(74) 评论(0) 推荐(0) 编辑
摘要:pandas.DataFrame 进行新增列操作的五种方法:insert、reindex、loc、obj[‘col’]、concat。 data: a b c 0 1 2 3 1 4 5 6 2 7 8 9 一、insert 方法 使用 pandas 的 insert 方法,第一个参数指定插入列的位 阅读全文
posted @ 2022-11-06 10:50 华小电 阅读(1882) 评论(0) 推荐(0) 编辑
摘要:1.双y轴绘制 关键函数:twinx() # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from matplotlib import rc rc('mathtext', default='regu 阅读全文
posted @ 2022-10-21 09:07 华小电 阅读(195) 评论(0) 推荐(0) 编辑
摘要:####UI文件 # -*- coding: utf-8 -*- from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, QMetaObject, QObject, QPoint, QRect, QSize, 阅读全文
posted @ 2022-10-20 21:22 华小电 阅读(571) 评论(0) 推荐(0) 编辑
摘要:import matplotlib.pyplot as plt from scipy.optimize import curve_fit import numpy as np def func(x, a, b, c): # 拟合的方程 return a * np.exp(-b * x) + c de 阅读全文
posted @ 2022-10-17 10:35 华小电 阅读(518) 评论(0) 推荐(0) 编辑
摘要:1.数据 x = np.random.uniform(-5, 5 ,size=100) X = x.reshape(-1, 1) y = x**2 + x +2 + np.random.normal(0, 1, size = 100) 2. 拟合 ploy = PolynomialFeatures( 阅读全文
posted @ 2022-10-17 10:16 华小电 阅读(136) 评论(0) 推荐(0) 编辑
摘要:使用sklearn.preprocessing.PolynomialFeatures来进行特征的构造。 它是使用多项式的方法来进行的,如果有a,b两个特征, 那么它的2次多项式为(1,a,b,a2,ab,b2)。 那么它的3次多项式为($1,a,b,a^2,ab, b^2, a^3, a^ 阅读全文
posted @ 2022-10-16 22:52 华小电 阅读(82) 评论(0) 推荐(0) 编辑
摘要:QFileDialog有四项功能 1.打开文件夹 getExistingDirectory() def openfolder(self): self.folder = QFileDialog.getExistingDirectory(self) print(self.folder) 2.打开特定文件 阅读全文
posted @ 2022-10-12 13:42 华小电 阅读(898) 评论(0) 推荐(0) 编辑
摘要:在Qt Designer中先建立UI,转成py文件,文件名为:plot_ui.py # -*- coding: utf-8 -*- ################################################################################ ## 阅读全文
posted @ 2022-10-10 10:17 华小电 阅读(262) 评论(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 华小电 阅读(189) 评论(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 华小电 阅读(124) 评论(0) 推荐(0) 编辑
摘要:DataFrame 提取一行后 就变成Series,DF的列(columns) 就变成Series的索引(index ),再保存到csv文件,格式就乱了 处理办法:将Series的value提取出来,变成list格式,用append()将所有提起的数据放在一起,再转成DataFrame格式,再添加原 阅读全文
posted @ 2022-07-04 09:52 华小电 阅读(619) 评论(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 华小电 阅读(401) 评论(0) 推荐(0) 编辑
摘要:在使用set_xticklabels时,报错 UserWarning: FixedFormatter should only be used together with FixedLocator 究其原因,原来set_xticks()和set_xticklabels()需要同时使用,缺一不可 阅读全文
posted @ 2022-05-15 10:36 华小电 阅读(1200) 评论(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 华小电 阅读(50) 评论(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 华小电 阅读(313) 评论(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 华小电 阅读(637) 评论(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 华小电 阅读(27) 评论(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 华小电 阅读(440) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示