-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy path常用代码.txt
More file actions
244 lines (174 loc) · 7.43 KB
/
Copy path常用代码.txt
File metadata and controls
244 lines (174 loc) · 7.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
去重
df = df.drop_duplicates().reset_index(drop=True)
删除某一列
df2=df2.drop(cols,axis=1)
删除两行
df.drop(index=[0, 1])
date转字符串
from datetime import datetime, date, time
d = date.fromisoformat('2018-09-22')
t = time.fromisoformat('16:28:22')
dt = datetime.fromisoformat('2018-09-22')
sdate = pd.to_datetime(ds).strftime('%Y-%m-%d')
st = "2019-01-20 00:00:00"
dt = datetime.datetime.strptime(st, '%Y-%m-%d %H:%M:%S')
st = "2019-01-20"
dt = datetime.datetime.strptime(st, '%Y-%m-%d')
start=pd.to_datetime('2017-01-01')
修改类型
train['tf_status'] = t1['tf_status'].astype(np.int64)
修改日期类型
df['ds'] = pd.to_datetime(df['ds'])
修改字段名
df.rename(columns={'#studentid':'studentid'}, inplace = True)
#加年月
df['year']=df.datetime.apply(lambda x: x.year)
df['month'] = df.datetime.apply(lambda x: x.month)
df['year'] = df['year'].astype(np.int64)
df['month'] = df['month'].astype(np.int64)
删除字段
df.drop(['#id'], axis=1, inplace=True)
查看数据中顶部10%的数据
print(df.weeks.quantile(np.arange(.9,1,.01)))
设置索引
df = df.set_index(['hetongdetailid'])
判断空值
print("在 cat 列中总共有 %d 个空值." % df['cat'].isnull().sum())
print("在 review 列中总共有 %d 个空值." % df['review'].isnull().sum())
df[df.isnull().values==True]
df = df[pd.notnull(df['review'])]
排序
df.sort_values(by="x1",ascending= False)
模糊查询
df_remark_tf[df_remark_tf["content_method"].str.contains(keystring)]
修改字段类型
df_appraise['deptid'] = df_appraise['deptid'].astype(np.int64)
修改数据(https://blog.csdn.net/zhangchuang601/article/details/79583551)
df.loc[1,['name','age']] = ['bb',11]
df.iloc[1,2] = 19#修改某一无
df.loc[df[df.htid.isin(ids)].index,"y"]=1
保存数据库
df.to_sql(name='predict',con=mysql_engine,if_exists = 'replace')
生成日期
dt = datetime.datetime(year, month, 1)
查看顶部10%数据分布
print(movie_rating_count['totalRatingCount'].quantile(np.arange(.9,1,.01)))
#-------plotly.express-------------------------
#折线图
import plotly.express as px
fig = px.line(df, x='date', y='y_true',
labels={'date':'日期', 'y_true':'话务量'},
markers=True)
fig.update_xaxes(tickformat = "%Y-%m-%d", hoverformat = "%Y-%m-%d")
fig.update_layout(title_text="热线部门日业务量趋势图", title_x=0.5)
fig.update_traces(marker=dict(size=3)) #控制点的大小
fig.show()
#散点图
fig = px.scatter(df, x="真实订单量", y="真实金额",hover_data=['did','日期'])
fig.update_traces(marker=dict(size=4)) #点的大小
fig.show()
----------------------------------
1、nohup command &
例如 nohup jupyter notebook &
2、找到进程PID(关闭在前面后台执行的进程的步骤,首先找到其进程PID)
ps -ef | grep xxxx
ps -ef 查看本机所有的进程;grep xxxx代表过滤找到条件xxxx的项目
3、kill掉进程
kill -9 具体的PID
-------------打开指定端口-------------------------------------
firewall-cmd --zone=public --add-port=8504/tcp --permanent
firewall-cmd --reload
netstat -ntlp //查看当前所有tcp端口·
netstat -ntulp |grep 8888 //查看所有1935端口使用情况
------------------更新pip命令----------------------------------------
python -m pip install --upgrade pip
-------------搭建虚拟环境-----------------------------
# 创建虚拟环境
conda create --name yourenvname python=3.8
# 进入虚拟环境
conda activate yourenvname
#退出虚拟环境
conda deactivate
#删除虚拟环境
conda remove -n py39 --all
# 在jupyter notebook中添加虚拟环境
python -m ipykernel install --user --name yourenvname --display-name "display-name"
------------------在jupyter notebook里面添加虚拟环境----------------------------------------
1.cmd进入虚拟环境(torch_env)
activate torch_env
2.pip install ipykernel ipython
回车
3.ipython kernel install --user --name torch_env
回车
4.再次进入jupyter notebook
右上角,new,即可选择需要的虚拟环境。
5.另外,如果需要在指定文件夹中打开jupyter notebook,只需要打开文件夹所在位置,点击搜索框左边的位置框,输入cmd,再输入jupyter notebook,即可将路径设为自己需要的。
在jupyter 中删除虚拟环境
6.jupyter kernelspec uninstall myenv
---------pip install 镜像安装-----------------------------------------
pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple
--------------------图个格式转换---------------------------------------------------
from PIL import Image
#base64转PIL
def base64_to_pil(img_base64):
base64_decoded = base64.b64decode(img_base64)
byte_stream = io.BytesIO(base64_decoded)
pil_image = Image.open(byte_stream)
return pil_image
#PIL转base64
def image_to_base64_str(pil_image):
byte_arr = io.BytesIO()
pil_image.save(byte_arr, format='PNG')
byte_arr = byte_arr.getvalue()
return str(base64.b64encode(byte_arr).decode('utf-8'))
#数组转base64(方法一)
pil_image = Image.fromarray(cv2.cvtColor(image_array, cv2.COLOR_BGR2RGB))
image_base64 = image_to_base64_str(pil_image)
#数组转base64(方法二)
retval, buffer = cv2.imencode('.png', img_mask_face_array)
image_mask_face_base64 = base64.b64encode(buffer).decode('utf-8')
# 将PIL转换为NumPy数组
array_image = np.array(pil_image)
array_image = np.asarray(pil_image)
#array to pil
from PIL import Image
pil_image = Image.fromarray(image_array)
音量调节
alsamixer
常用开机自启管理命令总结
拷贝.service文件: sudo cp mcp_pipe.service /etc/systemd/system/mcp_pipe.service
赋权限:sudo chmod 644 /etc/systemd/system/mcp_pipe.service
重新加载 systemd 配置:sudo systemctl daemon-reload
启用开机自启: sudo systemctl enable mcp_pipe.service
禁止开机自启: sudo systemctl disable mcp_pipe.service
立即启动: sudo systemctl start mcp_pipe.service
立即停止: sudo systemctl stop mcp_pipe.service
重启服务: sudo systemctl restart mcp_pipe.service
查看状态: sudo systemctl status mcp_pipe.service
查看实时日志:journalctl -u mcp_pipe.service -f
第一步:在 GitLab 上创建一个新的空项目
在您的浏览器中打开 GitLab,并导航到 xiaozhi 组。
点击页面右上角的蓝色按钮 "New project"。
选择 "Create blank project"。
在 "Project name" 字段中,为您的项目命名,例如 simple-py-xiaozhi。
确保 "Project slug" 和 "Project URL" 是正确的。
您可以选择将 "Visibility Level" 设置为 "Private" 或 "Internal"。
不要 勾选 "Initialize repository with a README"。因为您本地已经有项目了,所以要创建一个空的项目。
点击 "Create project"。
1. cd D:\work\py-xiaozhi\simple-py-xiaozhi
2. git init
3. git remote add origin [您在GitLab上创建的项目的URL]
4. git add .
5. git commit -m "Initial commit"
6. git push -u origin main
---------esp32编译----------------------
cd ~/work/esp-idf
source ./export.sh
1. idf.py set-target esp32s3
2. idf.py menuconfig
3. idf.py build
------生成单个固件文件-----
4. cd build ,
5. python3 -m esptool --chip esp32s3 merge_bin -o ../xiaozhi_ok.bin @flash_args
6. 烧录固件:
python -m esptool --chip esp32s3 -p /dev/tty.usbmodemXXXX -b 460800 --before default_reset --after hard_reset write_flash -z 0x0 xiaozhi.bin