美文网首页
python bug记录

python bug记录

作者: 漱衣仁止 | 来源:发表于2021-01-25 17:00 被阅读0次

按行读dataframe

for value in test.values:

    print(value)

         data = dict(zip(test.columns,value))

for ri,row in test.iterrows():                                             # 必须要加ri,要不然打印出来的结果不是一对一的

    print(row)

    print(ri)

    print(dict(zip(test.columns,row)))

    data = dict(zip(test.columns,row))

使用stack时,若数据中原先有NULL,fillna和未fillna的区别

fillna("NA")时会将即使原来为NULL的行也保留下来

d.read_csv(path,encoding='utf-8').set_index(index_columns).stack().reset_index().rename(columns=columns)

不进行赋值,会自动把原先为NULL的行删除掉

d.read_csv(path,encoding='utf-8').fillna("NA").set_index(index_columns).stack().reset_index().rename(columns=columns)

启示:数据减少的时候注意查看原因

lambda+fillna(method='ffill',axis=1)

在用assign和lambda 函数的时候,想要给某一列的NULL用另外一列赋值的时候,注意最后跟上想取列的列名,否则python会自动取前面的一列。

lambda x: x[['gs_correct','hgnc_id_map']].fillna(method='pad',axis=1)['hgnc_id_map']

取的是'hgnc_id_map'列

lambda x: x[['gs_correct','hgnc_id_map']].fillna(method='pad',axis=1)

取的是gs_correct列

replace("a",None)

replace任何字符串为None值时都是会填充上面一行的值,官网文档有解释。

如果想替换为空就写replace("a",'')

s = pd.Series([10, 'a', 'a', 'b', 'a'])

s.replace('a', None)

核对数据时发现excel中有的python中未查到

结果发现不是代码的问题,是excel不区分大小写的!!!

所以导致某个sequence只相差一个大小写,在excel中看到了,在python中处理后的数据没查到,是本来输入的sequence不对,错了一个字母的大小写。


pandas 使用 df.product 条件筛选报错Keyerror:False

这个列名可能是python的方法,试着用索引取列名就可以了,详见https://www.cnblogs.com/wanglvtao/p/10795779.html

tensorboard没有数据

在terminal 中输入命令tensorboard --logdir=logs --port=6007

如果显示没有数据的话原因是logs的路径是相对路径,需要把目录cd到log文件夹的上一层

axis

axis在apply函数中0代表列,1代表行;在drop函数中0代表行,1代表列

append/extend two list get None

a = [1,2,3]

b = [4,5,6]

c = a.extend(b) or c = a.append(b) or d.append(a.extend(b))都会get None,这是因为extend/append is an in-place function i.e. It will make the changes to the original list itself. From the docs Extend the list by appending all the items in the given list;

如果写成a.extend(b) print(a)则是两者合并之后的样子,就是不要赋值,三个的同样a.extend(b) d.append(a)。

如果非要赋值的,可以list = list1 + list2 or final_list = [*list_1, *list_2]

相关文章

  • python bug记录

    for value in test.values: print(value) data = dict(...

  • Python bug 问题汇总

    记录一些 Python 使用过程出现的 Bug 解决策略。 PyInstaller 1 UnicodeDecode...

  • python处理logger日志

    前言: 在实际的项目开发过程中,为了准确的定位出bug,需要对错误进行日志记录,这里简要记录一下使用python的...

  • python 解码字节流 decode bytes

    之前使用python解码二进制字节流,遇到各种各样的bug,现在对各种问题进行总结记录 一. 解码报错:'utf-...

  • Bug Board

    记录bug -bash: ./app: no such file or directory Bug产生背景:项目里...

  • BUG 记录

    EditText 光标 textCursorDrawablea. 必须设置图片b. 必须设置大小 下划线andr...

  • BUG 记录

    1、问题:POP某个view出来的时候一直不出现。 原因:程序运行,找了好久才发现,视图上出现两个windo...

  • bug记录

    1、 解决办法:添加SystemConfiguration.framework 2.这个是引用NSDataAddi...

  • Bug记录

    TabLayout如果不设置tabIndicatorColor会抛如下异常 在MIUI上发现某个横向的Recycl...

  • BUG记录

    AccessibilityService 使用不当,影响到了系统音量调节条的延时消失,多达20秒(正常为3-4秒)...

网友评论

      本文标题:python bug记录

      本文链接:https://www.haomeiwen.com/subject/gmrizktx.html