
python
超级无敌可爱的小番茄
这个作者很懒,什么都没留下…
展开
-
python 报错TypeError: ‘in <string>‘ requires string as left operand, not int
python 报错TypeError: 'in ’ requires string as left operand, not int原因:类型没对齐username = ‘root’tn.write(username + str(’\n’))就会报错应该改成tn.write(username.encode(‘ascii’) + str(’\n’))python3 中 文本字符串类型(unicode编码)被命名为str,字节字符串类型被命名为bytes,其中 str encode原创 2022-03-25 22:35:17 · 17463 阅读 · 0 评论 -
VScode 安装python 和 jupyter notebook
VScode 安装python要安装插件和解释器,插件在VScode里面装,解释器在官网下载,然后启动解释器(activate 有一个python interpreter seletion)装插件的同时会自动装上 jupyter notebook用pip安装需要的包pip install numpy...原创 2022-03-25 22:31:59 · 1824 阅读 · 0 评论 -
python 可视化 Data Vistualization
Data Vistualizationlibraries to plot:matplotlib (plt)pandas .plot()seaborn (sns)bar plotrug plots(easy to see distributions)histograms= bar + (areas represent proportions) default: show counts on y-axis. ‘density = True’ : the total areas sums原创 2022-03-25 20:35:39 · 1660 阅读 · 0 评论 -
python 更换列名
dataframe 更换列名# 更换列名,同时显示出来df.rename(columns={'a':'A'}, inplace=Ture)# 更换列名,不显示出来 inplace = False(默认)# 求取每一列(或某一列)的中位数,众数,均值,方差等df.groupby('key').aggregate(['min', np.median, max])# 把True/False写成1/0# 法1import numpy as npa = np.array([True, False原创 2022-03-25 19:56:54 · 14461 阅读 · 1 评论