![](https://img-blog.csdnimg.cn/20200219165854439.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
python
各种python相关内容
JohnManLi
分享,学习
展开
-
Pandas 删除指定行
定位要删除的行需求:删除指定列中NaN所在行。如下图,’open‘ 列中有一行为NaN,定位到它,然后删除。定位:df[np.isnan(df['open'])].index# 这样即可定位到所在行的index,然后对该index进行drop操作即可删除行df.drop(df[np.isnan(df['open'])].index, inplace=True)# 直接drop对应indx即可删除该行...原创 2020-07-01 15:02:12 · 2971 阅读 · 0 评论 -
查找某个字符在字符串的位置
str_1='wo shi yi zhi da da niu 'char_1='i'nPos=str_1.index(char_1)print(nPos)运行结果:7========是使用find==========str_1='wo shi yi zhi da da niu 'char_1='i'nPos=str_1.find(char_1)print(nPos)结果:5原创 2020-06-28 10:49:21 · 1618 阅读 · 1 评论 -
string 转list
train_set_['his_list']=list(train_set_['his_list'].map(lambda x: literal_eval(x)))原创 2020-06-22 13:41:58 · 315 阅读 · 0 评论 -
list列表删除元素 python
del:根据索引值删除元素del listname[start : end]pop():根据索引值删除元素listname.pop(index)remove():根据元素值进行删除listname.remove(values)clear():删除列表所有元素清空列表:listname.clear()...原创 2020-06-10 13:57:51 · 187 阅读 · 0 评论 -
tf.reset_default_graph()
Variable W already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at解决方案:加入:tf.reset_default_graph()import tensorflow as tftf.reset_default_graph()json_pritimive = "******.custom.nlp.Text.原创 2020-06-10 10:46:23 · 347 阅读 · 0 评论 -
解决编码问题
TypeError: a bytes-like object is required, not 'str'问题出在python3.5和Python2.7在套接字返回值解码上有区别:python bytes和str两种类型可以通过函数encode()和decode()相互转换,str→bytes:encode()方法。str通过encode()方法可以转换为bytes。bytes→str:decode()方法。如果我们从网络或磁盘上读取了字节流,那么读到的数据就是bytes。要把bytes变...原创 2020-06-08 19:18:58 · 172 阅读 · 0 评论 -
转换位串到utf-8字符串
使用str(string[, encoding])对数组进行转换如:\xe8\xa3\x85\xe5\xa4\x87\xe4\xba\xa4\xe6\x98\x93>>> str(req.readall(),'utf-8')原创 2020-03-31 18:21:26 · 282 阅读 · 0 评论