python
heianduck
这个作者很懒,什么都没留下…
展开
-
WindTerm使用(暂停更新)
作为一个经常和代码以及服务器打交道的人,连接远程服务器所使用的工具肯定是越方便越好。目前,我使用的是xshell5和MobaXterm两个。Xshell最新的是7,破解版的我懒得去找,那xshell7免费使用一段时间后,就得付费;如果使用免费版的话,选项卡好像最多只能4个,这方面对我来说太鸡肋,就没有用7。我现在使用的是5版本的,没有选项卡上限。唯一的缺点就是对应的xftp鼠标点击太频繁时,会卡死闪退,但这点我还是能够接受的。因人而异吧....................................原创 2022-06-14 16:55:19 · 38850 阅读 · 152 评论 -
pandas-cut 函数
前言数值数据在数据分析中很常见。 通常,您拥有连续的、非常大的比例或高度偏斜的数值数据。有时,将这些数据分成离散的区间会更容易。 当值被划分为有意义的类别时,这有助于执行描述性统计。例如,我们可以将确切的年龄划分为幼儿、儿童、成人和老年人。Pandas 内置的 cut() 函数是将数值数据转换为分类数据的好方法。参数及解释pandas.cut(x, bins, right=True, labels=None, retbins=False,\ ...原创 2022-04-25 17:23:20 · 11536 阅读 · 2 评论 -
Streamlit(十) widgets-file_uploader
st.file_uploader源码路径:${python}\Lib\site-packages\streamlit\elements\file_uploader.pyst.file_uploader(label, type=None, accept_multiple_files=False, key=None,\ help=None, on_change=None)#如果 accept_multiple_files 为 False,则返回 None 或 Uploaded原创 2022-02-08 16:09:08 · 5114 阅读 · 4 评论 -
Django crontab 定时执行任务
1. 前期工作1.1 安装django-crontabpip install django-crontab1.2 添加app名称到 settings.py配置文件中INSTALLED_APPS = ( 'django_crontab', ... )2. 布置定时任务2.1、定义定时任务函数def test(): print 123 #你要执行的任务函数2.2、在 settings.py中的最后增原创 2022-01-22 19:17:41 · 824 阅读 · 0 评论 -
Streamlit(九) widgets-input
st.text_input / st.number_input / st.date_input / st.time_input源码路径:${python}\Lib\site-packages\streamlit\elements\text_widgets.py(number_input.py, time_widgets.py)st.text_inputst.text_input(label, value="", max_chars=None, key=None,\原创 2022-01-16 14:29:57 · 1960 阅读 · 1 评论 -
Original error was: DLL load failed: 找不到指定的模块
Traceback (most recent call last): File "c:/Users/19051/Desktop/getPMSampleList.py", line 7, in <module> import pandas as pd File "D:\softwareInstall\miniconda37\lib\site-packages\pandas\__init__.py", line 17, in <module> "Unable t.原创 2022-01-14 10:28:30 · 669 阅读 · 0 评论 -
Streamlit(八) widgets-slider
st.slider / st.selectSlider源码路径:${python}\Lib\site-packages\streamlit\elements\slider.py(selectSlider.py)st.sliderst.slider(label, min_value=None, max_value=None, value=None, \ step=None, format=None, key=None, help=None, on_change=Non原创 2022-01-13 16:45:56 · 1228 阅读 · 0 评论 -
Streamlit(七) widgets-selectbox
st.selectbox / st.multiselect源码路径:${python}\Lib\site-packages\streamlit\elements\selectbox.py(multiselect.py)st.selectboxst.selectbox(label, options=OptionSequence, index=0, format_func="", key=None, help=None, on_change=None)label:一个简短的标签,向用户解原创 2022-01-12 16:05:42 · 4030 阅读 · 0 评论 -
pandas 向已有的excel指定的行和列添加数据
现有一个excel表格:import pandas as pdimport openpyxldf1 = pd.DataFrame( { "num1": [21,25,56,11], "num2": [31,35,36,12], "num3": [41,45,46,14], }, index=[0, 1, 2,3],)df1#用openpyxl打开excelwb=openpyx.原创 2022-01-11 13:25:51 · 11211 阅读 · 0 评论 -
Streamlit(六) widgets-checkbox
st.checkboxst.checkbox(label, value=False, key=None, help=None, on_change=None)label:一个简短的标签,向用户解释此按钮的用途value:当它第一次渲染时预选复选框。这将在内部转换为 bool。说白了,就是初始有没有备选key:一个可选的字符串或整数,用作小部件的唯一键。如果省略,将根据小部件的内容为小部件生成一个键。同一类型的多个小部件可能不会共享相同的密钥help:当按钮悬停在上面时显示的可选工具提示。原创 2022-01-10 15:18:49 · 1871 阅读 · 0 评论 -
Streamlit(五) widgets-button
st.button / st.download_buttonst.buttonst.button(label, key=None, help=None, on_click=None, args=None, kwargs=None)label:一个简短的标签,向用户解释此按钮的用途。key:一个可选的字符串或整数,用作小部件的唯一键。如果省略,将根据小部件的内容为小部件生成一个键。同一类型的多个小部件可能不会共享相同的密钥。help:当按钮悬停在上面时显示的可选工具提示。on_click原创 2022-01-10 15:10:22 · 5523 阅读 · 2 评论 -
mac ERROR: Failed building wheel for cytoolz
本人自己的电脑使用的是mac,在一次安装cytoolz过程中报错了,报错信息一大堆,关键的是:ERROR: Failed building wheel for cytoolzerror: command '/usr/bin/clang' failed with exit code 1baidu google了一会:在命令行:xcode-select --install再安装就可以了。...原创 2022-01-07 19:58:28 · 980 阅读 · 0 评论 -
(207, b“Invalid column name ‘xx‘ SQL Server error: Check messages from the SQL Server\n“)
Mysql想插入数据有点问题代码是:sample_cmd = 'SELECT s.InfoId, s.UserName, s.Disease , s.Defined5, r.InfoId\ InfoId1,r.ReportDate FROM dbo.J_SampleRegister s inner \join (SELECT distinct InfoId,ReportDate,Id FROM dbo.J_Report)\ r on s.InfoId=r.InfoId WHERE s.Di原创 2022-01-05 16:34:37 · 3547 阅读 · 1 评论 -
Streamlit(四) - st.dataframe
将数据框显示为交互式表格。st.dataframe(data=None, width=None, height=None)data: 如果 'data' 是一个 pandas.Styler,它将用于设置其底层 DataFrame 的样式。 Streamlit 支持自定义单元格值和颜色。width: 宽度。如果没有,则使用基于页面宽度的默认宽度。height: 高度。如果没有,则使用默认高度。df = pd.DataFrame( np.random.randn(50, 20.原创 2022-01-04 14:32:52 · 6210 阅读 · 1 评论 -
Streamlit(三) - text elements
st.markdownimport streamlit as stimport pandas as pdimport numpy as npst.markdown(body, unsafe_allow_html=False)markdown语法:GitHub Flavored Markdown Specst.markdown('Streamlit is **_really_ cool**.')st.title("st.title")st.header("st.header.原创 2021-12-29 11:56:54 · 722 阅读 · 0 评论 -
Streamlit(二) - write_magic
st.write(*args, **kwargs)write(string) 打印格式化的 Markdown 字符串,支持 LaTeX 表达式和表情符号短代码。write(data_frame) :将 DataFrame 显示为表格。write(error) :打印异常。write(func) :显示有关函数的信息。write(module) :显示有关模块的信息。write(dict) :在交互式小部件中显示 dict。write(mpl_fig) :显示 Matplotlib 图。w原创 2021-12-29 11:54:08 · 1588 阅读 · 0 评论 -
Streamlit - 自学中(一)
前面简单学习过pyWebio,但是这种类型的只适合简单的小程序,甚至左右布局的方式都没有(也有可能我没找到),目前我现在使用他的应用就只是那个sanger。 现在想学习下Streamlit,特此记录,因为是从头开始,大部分还是根据官方文档来,学习完了之后,才是自己尝试写应用。Install#Python 3.7 - Python 3.9#在使用pip安装时,请保证你经常使用的python和其对应的pip是同一个版本,经常看到有人明明已经安装成功了,但是impor...原创 2021-12-28 11:44:46 · 1445 阅读 · 4 评论 -
pandas - loc/iloc
loc通过label(s) 或者 布尔数组 来选择行或者列import pandas as pd#这里设置"行数"作为indexdata = pd.read_excel("table1.xlsx","Sheet1",index_col="行数")按标签筛选行#单行,返回一个Seriesdata.loc['hang2']#多行,不连续的,返回一个dataFramedata.loc[['hang1','hang4']]#多行,连续data.loc['..原创 2021-12-22 13:58:34 · 966 阅读 · 0 评论 -
python/R 绘制圣诞树
圣诞节快到了,想着用python、r来画画圣诞树玩,就在网络上各种找方法,不喜勿喷哈~~Python1、import turtlescreen = turtle.Screen()screen.setup(800,600)circle = turtle.Turtle()circle.shape('circle')circle.color('red')circle.speed('fastest')circle.up()square = turtle.Turtle()squa原创 2021-12-21 12:59:57 · 5736 阅读 · 5 评论 -
pandas.str.split - 一列分多行
每一行分的列数相同(即分隔符数目一致)import pandas as pddata = pd.read_excel("normal_same_split.xlsx","Sheet1")datadata.assign(上课地点=data['上课地点'].str.split(';')).explode('上课地点')多个分隔符import pandas as pddata2 = pd.read_excel("normal_same_mult_split.xlsx","Sh.原创 2021-12-10 13:24:40 · 1142 阅读 · 0 评论 -
pandas.str.split - 一列分多列
昨天我在逛CSDN问答的时候,看见有人问起panda拆分单元格成多行的事,我今天就记录下,分为“一列分多列” 以及 “一列分多行”。每一行分的列数相同(即分隔符数目一致)import pandas as pddata = pd.read_excel("normal_same_split.xlsx","Sheet1")data#去除"上课地点"列split1 = data.drop("上课地点",axis=1)# 分列split2 = data['上课地点'].str.split原创 2021-12-10 11:58:58 · 3467 阅读 · 2 评论 -
docxtpl - 字典传值
The propeller is {{tag_1}} for spicy food{{tag_2}}.The propeller is{{tag_1}}for spicy food{{tag_2}}from docxtpl import DocxTemplate# With old docxtpl version, "... for spicy ..." was replaced by "... forspicy..."# This test is for checking that...原创 2021-12-09 16:20:02 · 249 阅读 · 0 评论 -
docxtpl - 合并段落
from docxtpl import DocxTemplatetpl = DocxTemplate('templates\\merge_paragraph_tpl.docx')context = { 'living_in_town': True,}tpl.render(context)tpl.save('templates\\output\\merge_paragraph.docx')原创 2021-12-09 16:17:28 · 411 阅读 · 0 评论 -
docxtpl - 合并单元格
from docxtpl import DocxTemplatetpl = DocxTemplate('templates\\horizontal_merge_tpl.docx')tpl.render({})tpl.save('templates\\output\\horizontal_merge.docx')原创 2021-12-08 09:53:03 · 2644 阅读 · 2 评论 -
docxtpl - 向表格里插入图片
以写文件的形式将图片插入,循环变量,循环插入图片# -*- coding: utf-8 -*-'''Created : 2017-01-14@author: Eric Lapouyade'''from docxtpl import DocxTemplate, InlineImage# for height and width you have to use millimeters (Mm), inches or points(Pt) class :from docx.share原创 2021-12-08 09:51:29 · 2330 阅读 · 0 评论 -
python-PyWebIO 输入 (自学中)
输入函数清单函数 简介 input 文本输入 textarea 多行文本输入 select 下拉选择框 checkbox 勾选选项 radio 单选选项 slider 滑块输入 actions 按钮选项 file_upload 文件上传 input_group 输入组 input_update 更新输入项 Input-文本输入pywebio.input.input(label='', ty原创 2021-11-26 15:44:35 · 7069 阅读 · 9 评论 -
python-PyWebIO 组件(自学中)
Overview我们已经知道,PyWebIO中的输入函数是阻塞式的,输入表单会在成功提交后被销毁。在大多数场景下,使用这种方式接收用户输入已经够用了。但在一些场景下,你或许希望输入表单在提交后不消失,并且可以继续接收输入。所以,PyWebIO提供了pin模块来实现持续性输入。pin模块主要有3部分内容:pin 组件(widgets) pin_wait_change() pin_update()Pin widgetspin_input每个pin组件函数都对应一个input模块...原创 2021-12-07 16:47:16 · 5654 阅读 · 0 评论 -
docxtpl - 页眉页脚-替换图片-inline
from docxtpl import DocxTemplate, InlineImage# for height and width you have to use millimeters (Mm), inches or points(Pt) class :from docx.shared import Mmtpl = DocxTemplate('templates\\header_footer_inline_image_tpl.docx')context = { 'inlin...原创 2021-12-07 10:51:52 · 1400 阅读 · 0 评论 -
docxtpl - 页眉页脚-替换图片-预留图片位置
from docxtpl import DocxTemplateDEST_FILE = 'templates\\output\\header_footer_image.docx'tpl = DocxTemplate('templates\\header_footer_image_tpl.docx')#替换字符串context = { 'mycompany': 'The World Wide company',}#替换图片tpl.replace_media('templates...原创 2021-12-07 10:51:09 · 645 阅读 · 0 评论 -
docxtpl -页眉页脚-默认替换
from docxtpl import DocxTemplatetpl = DocxTemplate('templates/header_footer_entities_tpl.docx')context = { 'title': 'Header and footer test',}tpl.render(context)tpl.save('output/header_footer_entities.docx')原创 2021-12-07 10:50:15 · 233 阅读 · 0 评论 -
python-PyWebIO 输出 (自学中)
output 基本输出from pywebio.output import *# Text Outputput_text("Hello world!")# Table Outputput_table([ ['Commodity', 'Price'], ['Apple', '5.5'], ['Banana', '7'],])# Image Outputput_image('https://www.python.org/static/img/py.原创 2021-12-06 14:22:04 · 7410 阅读 · 3 评论 -
docxtpl - 页眉页脚-指定替换
from docxtpl import DocxTemplatetpl = DocxTemplate('templates/header_footer_tpl.docx')sd = tpl.new_subdoc()p = sd.add_paragraph( 'This is a sub-document to check it does not break header and footer')context = { 'title': 'Header and foote...原创 2021-12-06 10:39:41 · 381 阅读 · 0 评论 -
docxtpl - 多行多列-dynamic_table
Tables with dynamic count of columns.from docxtpl import DocxTemplatetpl = DocxTemplate('templates/dynamic_table_tpl.docx')context = { 'col_labels': ['fruit', 'vegetable', 'stone', 'thing'], 'tbl_contents': [ {'label': 'yellow',.原创 2021-12-05 10:33:44 · 1082 阅读 · 0 评论 -
docxtpl - 自定义过滤-custom_jinja_filters
The float value is {{ base_value_float }}The string value is {{ base_value_string }}The filter modified float value is {{ base_value_float | my_filterB(2)}}The filter modified string value is {{ base_value_string | my_filterA(‘Deric’)}}from do原创 2021-12-05 10:32:04 · 259 阅读 · 0 评论 -
docxtpl - 单元格背景填充-cellbg
With docxtpl, you can change table cell background color dynamically, just add the cellbg tag in the cell you want to set.from docxtpl import DocxTemplate, RichTexttpl = DocxTemplate('templates/cellbg_tpl.docx')context = { 'alerts': [ .原创 2021-12-05 10:30:26 · 557 阅读 · 0 评论 -
python -- argparse - 命令行解析
argparse是python标准库里面用来处理命令行参数的库>>>import argparse #首先导入模块>>>parser = argparse.ArgumentParser() #创建一个解析对象>>>parser.add_argument() #向该对象中添加你要关注的命令行参数和选项>>>parser.parse_args() #进行解析argparse.ArgumentParse原创 2021-12-04 22:05:53 · 390 阅读 · 0 评论 -
python - time
# timedemo.py 时间相关的模块演示# 演示的模块:time(时间) / datatime(处理 日期&时间) / calendar(日历)import timedef time_demo(): curtime = time.time() # 获取当前时间戳 time_str = time.ctime(curtime) # 转为string格式 print(time_str) # => Fri May 5 18:28:08 2017...原创 2021-12-03 09:53:15 · 108 阅读 · 0 评论 -
python -- shutil
复制文件:>>>import shutil>>>shutil.copyfile(a , b ) #将a文件复制成b,b不存在即生成,b存在即覆盖>>>shutil.copy(a, b) #b可以是文件,也可以目录,目录必须存在复制文件夹:shutil.copytree(src, dst) #递归复制文件夹,其中,src和dst均为目录,且dst不存在移动目录(文件):shutil.move(src, d原创 2021-12-03 09:49:52 · 1562 阅读 · 1 评论 -
python - 文本序列类型
1. upper2. lower3. title4. swapcase5. capitalize6. count('x')7. len(string)8. find9. index10. center11. ljust12. rjust13. zfill14. strip15. rstrip16. lstrip原创 2021-12-02 13:45:11 · 766 阅读 · 0 评论 -
python - 自定义字符串格式
本节包含str.format()语法和与旧的%格式比较的示例。目前支持三个转换标志:'!s'调用值的str(),'!r'调用repr(),'!a'调用ascii()。按位置访问参数:>>> '{0}, {1}, {2}'.format('a', 'b', 'c')'a, b, c'>>> '{}, {}, {}'.format('a', 'b', 'c') # 3.1+ only'a, b, c'>>> '{2}, {1}, {0原创 2021-12-02 10:13:37 · 953 阅读 · 0 评论