python 杂记

模电仿真软件:MultSim14.3下载与安装 在setup文件夹中,找到【Install.exe】文件,然后右键单击选择【以管理员身份运行】(这一步超级重要,否则可能会出现权限不足导致安装失败)!解压完成后,打开解压出来的文件夹,找到并进入【setup】文件夹(这一步很重要,不要进错文件夹)。4、在弹出的安装向导中,仔细阅读许可协议后,选择【我接受】,然后点击【下一步】继续安装过程。首先我们需要将下载好的安装包解压到本地文件夹,确保有足够的磁盘空间(建议至少5GB以上)!按照安装向导的提示,点击【下一步】继续(保持默认设置即可,除非你有特殊需求) 阅读详情

杂记

pandas实现SQL的in和not in

import pandas as pd

df = pd.DataFrame({'id':['3000','4001','4002','3005']})
ids = ['4001','4002']

# 方式一
df[df.id.isin(ids)]
df[~df.id.isin(ids)]

# 方式二
df.query("id in @ids")
df.query("id not in @ids")

pandas 实现 startswith

# 方式一
df[df.id.startswith("4")]
df[~df.id.startswith("4")]

# 方式二
df.query('id.startswith("4")', engine='python')
df.query('id.startswith("4")', engine='python')

爬虫问题

xpath语法

文本等于:/span[text()='确定']

文本不等于:/span[text()!='确定']

不包括文本:/span[not(text())]

不包括属性:/span[not(@class)]

不包括属性:/span[not(contains(@class,'expire'))]

包括属性:/span[contains(@class,'expire')]

selenium执行js脚本

js = "var q=document.getElementById('listdropdownUnitIdInfo-table').scrollTop=1000"
driver.execute_script(js)

上面的js脚本是,找到id为listdropdownUnitIdInfo-table 的元素,向下滚动1000个像素。可用于不规则的下拉选择框。

driver.execute_script('document.querySelector("#mini-27 > span > input").click()')

此js脚本是,根据select定位找到的元素,点击一下。

driver.execute_script("dat=document.getElementById('train_date'); dat.removeAttribute('readonly')")
driver.execute_script("document.getElementById('train_date').value='2020-10-01'")

此外还可以移除属性和修改属性。

selenium下拉选择框

from selenium.webdriver.support.select import Select

s = driver.find_element_by_xpath('//li[@class="select"]/select')
Select(s).select_by_value('100')

先将select的元素定位,注意:一定要定位到select。然后使用**Select().select_by_value(‘100’)**选择元素。

便捷使用xpath/js/select定位元素

F12进入开发者模式,在chrome/FireFox中,点击想要定位的元素,右键复制,点击想要的语法,即可。

处理数据问题

处理时间问题

import time

day = int(time.strftime("%d", time.localtime()))  # 日
month = int(time.strftime("%m", time.localtime())) #月
year = int(time.strftime("%Y", time.localtime())) # 年

有关于日期的代码,一定要注意跨月/年的日期,多考虑一点,多测试

xlwings保存数据

app = xw.App(visible=False, add_book=False)
wb = app.books.open(文件路径)
sheet = wb.sheets[工作薄名]
sheet.range("a2").options(index=False, header=False).value = df
# df是一个DataFrame格式的数据

wb.save()
wb.close()
app.quit()

将两个列表合成一个二维列表

  1. 列表生成式
c = [[a[_], b[_]] for _ in range(len(qgzx))]

  1. zip压缩
list(zip(a,b))

# [(1, 4), (2, 5), (3, 6)]

pandas筛选多个

一般的筛选只需要,s[s[0] == 1],但是当需要筛选的对象有多个时,就有点麻烦,可以将每一个元素都进行一次筛选。也可以

s[list(map(lambda x: x not in list, s[0]))]

pandas连接数据

按行加,将数据纵向连接,使用pd.concat([])时,注意列名对应,需要时,可以将列名修改为想要的名字和顺序。

# 修改列名
s1.columns = [0, 1, 2, 3, 4, 5, 6, 7]
# 重新排序
ss = ss.reindex(columns=[0, 1, 2, 3, 4, 5, 6])

s = pd.concat([s1, s2])

按列加,将数据横向连接,使用pd.merge()时,需要确定按照那一列进行,对应连接。连接参数有on、left_on、right_on、left_index、right_index、left_index、right_index等等。

# 按照索引连接
pd.merge(s4, s5, right_index=True, left_index=True)

BMD101传感器协议解析与STM32实现(LCD显示波形) 1 前言 BMD101传感器是神念科技开发的心电传感器。目前有一些商家开发了BMD101传感器模块,基本上都是利用蓝牙直接传输数据到PC或手机端。而本文介绍通过串口将数据传送给单片机,并在单片机上完成数据解析和心电波形LCD显示的功能。 2 通信协议解读 BMD101 通过 UART 接口通信。这是一个标准的 UART 接口,定义为 1 个起始位,8 个数据位,1 停止位格式,波特率 57600。 串口输出的数据包格式如下: 包括Header(帧头)、data payload(数据有效载荷)、CRC校验 阅读详情

相关推荐

STM32F407通过SMBus协议精准读取BQ40Z50电池电量

本文详细介绍了STM32F407通过SMBus协议精准读取BQ40Z50电池电量的实现方法。从硬件连接到软件驱动开发,再到通信异常排查,提供了完整的解决方案。重点解析了SMBus协议的特殊时序要求、GPIO模拟驱动的关键代码,以及实际调试中的常见问题与对策,帮助开发者高效完成电池管理系统开发。

weixin_29189003的博客 250

python dataframe isin()实现sql的in

huitong[huitong['编号'].isin(['68','27'])]

qq_27866857的博客 1520

海康工业相机使用教程

海康工业相机连接电脑教程

qq_43251445的博客 2万+

pandas 对比两个dataframe实现sql的‘not in‘的效果

其实最终我去遍历dataframe然后拼 ‘not in’ 的sql去了。???? 这种方式(百度看到的)应该跑起来挺快的,记录一下,下次实验一下。 import pandas as pd df1=pd.DataFrame({'authorID':['12','34','56']}) df2=pd.DataFrame({'authorID':['12','56','78','97']}) original_users=set(df1[['authorID']].values.reshape(-1)) for

pycrossover的博客 1441

深入AOSP构建系统:从BUILD_FINGERPRINT的生成逻辑,看如何定制你的Android设备标识

本文深入解析AOSP构建系统中的设备指纹生成机制,详细介绍了BUILD_FINGERPRINT的生成逻辑及其在Android设备中的关键作用。通过分析多个指纹属性的区别与联系,以及如何定制设备标识,帮助开发者更好地理解和掌握Android系统构建过程。

weixin_27017211的博客 216

基于gem5模拟trace的cache模拟器的实现

在做计算机体系结构的时候,模拟器是一个重要且又有效的工具。其中gem5集成了gem和m5的优点,使用起来比较简单和方便。其中包括了se模式和fs模式,se模式是在gem5运行我们已经编译好的程序,可以获取cache,cpu状态等数据,fs模式下可以模拟操作系统,我们可以将我们自己修改的linux内核加载到哥们上运行。下面介绍了使用gem5的se模式,运行编译好的ARM可执行文件。获取访存的trac

gaoxiang的专栏 8891

web自动化测试_Web自动化测试 | 执行JavaScript脚本

简介JavaScript是运行在客户端(浏览器)和服务器端的脚本语言,允许将静态网页转换为交互式网页。可以通过 Python Selenium WebDriver 执行 JavaScript 语句,在Web页面中进行js交互。那么js能做的事,Selenium应该大部分也能做。WebDriver是模拟终端用户的交互,所以就不能点击不可见的元素,有时可见元素也不能点击。在这些情况下,我们就...

weixin_39954698的博客 887

京东风控算法工程师带你解读Action Model-精细化运营(上篇)

电影《蝴蝶效应》中,男主拥有回到童年改变过去的能力,虽然在剧中男主一次次穿越时空拯救世界,但由于他无法预见自己做出的抉择对未来产生的其他影响,最终还是没能阻止悲剧的发生。可见,一个好的决策需要衡量其对未来产生的影响。JDD风控算法团队本期为大家解惑最优决策难题的解决方法-Action Model。

JDD风控算法的博客 1916

Python 网络服务相关 杂记

个人所有文章整理在此篇,将陆续更新收录:知无涯,行者之路莫言终(我的编程之路) python.png 本文杂记了下面一些点 [1].Python的原生版Socket [2].python自带的模块:`wsgiref`的简单使用 [3].Python和Idea的爱恨情,pip装了模块但不能用,或飘红了但能用 [4].随手一说 jinja2 ...

张风捷特烈的博客 390

【深度学习新浪潮】OpenClaw跟机器人行业有哪些很好的研究结合点?

OpenClaw正通过"AI大脑+机器人肢体"的深度融合,重新定义机器人与人类的交互方式和自主操作能力。近期ROSClaw框架发布、人形机器人集成和空间计算试验等进展,标志着OpenClaw已从概念验证阶段进入实际应用落地期,为机器人行业带来了自然语言控制普及化具身智能平民化和跨平台开发标准化三大变革机遇。

专注:太空算力、AI infra、异构调度、大模型成本工程 228

华为OD统一考试 - 模拟消息队列(Java & Python& JS & C++ & C )

让我们来模拟一个消息队列的运作,有一个发布者和若干消费者,发布者会在给定的时刻向消息队列发送消息,

算法大师! 3517

课程学习 CV 北京邮电大学 鲁鹏(笔记一:杂记)

杂记

weixin_44845357的博客 269

SAP CDS View association 的工作原理,与数据库传统 join 操作的区别讲解

笔者前一篇教程,介绍了 SAP CDS View 里如何创建 association:本文就来一一对这些问题进行解答。首先我们来研究如何消费创建好的 SAP CDS View 中的 association 数据。在上图 ABAP Development Tool 里展示的 CDS View 界面,点击 F8 快捷键,进入 Data Preview 即数据预览界面。我们随便选中一条行项目,右键,发现右键菜单里,赫然有一条的菜单项。看来这个功能肯定和 association 相关了。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 996

Python 杂记

tuple: 元组,数组 A non-exhaustive list of features which are only available in 3.x releases and most likely won't be backported to the 2.x series: function annotations syntax for keyword-only argu

chinaren0001的专栏 983

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Python杂记

Python杂记 Using MD5 to check equality between files - Peterbe.com (Peter Bengtsson on Python, Zope, Kung Fu, London and photos) the ...

101

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

python杂记

python杂记 1.enumerate() 函数 enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中 语法 以下是 enumerate() 方法的语法: enumerate(sequence, [start=0]) 参数 sequence – 一个序列、迭代器或其他支持迭代对象。 start – 下标起始位置。 返回值 返回 enumerate(枚举) 对象。 实例 以下展示了使用 enumerate() 方

weixin_43342909的博客 609

Pythonic与Python杂记

Pythonic与Python杂记 一、用字典映射代替switch case语句 1、switch case语句: switch (day){ case 0: dayName = "Sunday"; ... ... ...

weixin_38477351的博客 252

python常用配置杂记

python常用配置杂记 xadmin后台管理 pip安装源 虚拟环境搭建 git版本控制器

Allen 416

Python2.7杂记

Python2.7杂记 文章目录Python2.7杂记关于print+与,的区别不换行\*与\** 关于print +与,的区别 其中“,”是用了连接两个不同的数据类型,“+”是用来连接两个相同的数据类型 不换行 print语句的结束后面加一个逗号 *与** *args是可变参数,args接收的是一个tuple; **kw是关键字参数,kw接收的是一个dict。 ...

Gowi的博客 460
上一篇: Hive 压缩和储存
下一篇: python操作word
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力生活的黄先生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值