草庐IT

that-dont-suck

全部标签

python - Matplotlib 错误 : "figure includes Axes that are not compatible with tight_layout"

添加后bbox_inches="tight"对于已经工作了几年的plt.savefig的调用,我得到了/usr/local/lib/python2.7/site-packages/matplotlib/figure.py:1744:UserWarning:ThisfigureincludesAxesthatarenotcompatiblewithtight_layout,soitsresultsmightbeincorrect有问题的数字似乎可以工作(现在没有truncationofannotations),但我想知道这个错误可能意味着什么以及是否有任何明显或已知的(无需深入研究复杂的

Python Pandas : Add a column to my dataframe that counts a variable

我有一个这样的数据框“gt”:orggrouporg11org21org32org43org53org63我想将列“count”添加到gt数据框以计算组的成员数,预期结果如下:orggroupcountorg112org212org321org433org533org633我知道如何对组中的一项进行计数,但不知道如何使所有组项的计数重复,这是我使用的代码:gtcounts=gt.groupby('group').count()有人可以帮忙吗? 最佳答案 调用transform这将返回一个与原始df对齐的Series:In[223]:

python : Assert that variable is instance method?

如何检查变量是否为实例方法?我正在使用python2.5。类似这样的:classTest:defmethod(self):passassertis_instance_method(Test().method) 最佳答案 inspect.ismethod如果您确实有方法,而不仅仅是您可以调用的东西,是您想知道的。importinspectdeffoo():passclassTest(object):defmethod(self):passprintinspect.ismethod(foo)#Falseprintinspect.isme

mongodb错误: how do I make sure that your journal directory is mounted

我在我的mac终端上输入mongod并得到以下错误:2015-04-27T22:11:46.471-0400W-[initandlisten]Detecteduncleanshutdown-/data/db/mongod.lockisnotempty.2015-04-27T22:11:46.479-0400ISTORAGE[initandlisten]**************oldlockfile:/data/db/mongod.lock.probablymeansuncleanshutdown,buttherearenojournalfilestorecover.thisisli

mongodb错误: how do I make sure that your journal directory is mounted

我在我的mac终端上输入mongod并得到以下错误:2015-04-27T22:11:46.471-0400W-[initandlisten]Detecteduncleanshutdown-/data/db/mongod.lockisnotempty.2015-04-27T22:11:46.479-0400ISTORAGE[initandlisten]**************oldlockfile:/data/db/mongod.lock.probablymeansuncleanshutdown,buttherearenojournalfilestorecover.thisisli

Python 调试器 : Stepping into a function that you have called interactively

Python很酷,但不幸的是,它的调试器不如perl-d。我在试验代码时经常做的一件事是从调试器中调用一个函数,然后单步执行该函数,如下所示:#NOTETHATTHISPROGRAMEXITSIMMEDIATELYWITHOUTCALLINGFOO()~>cat-n/tmp/show_perl.pl1#!/usr/local/bin/perl23subfoo{4print"hi\n";5print"bye\n";6}78exit0;~>perl-d/tmp/show_perl.plLoadingDBroutinesfromperl5db.plversion1.28Editorsuppo

python - 在字符串中查找 "one letter that appears twice"

我正在尝试使用RegEx(或者可能有更好的方法?)来捕捉一个字母是否在字符串中出现两次,例如我的字符串是:ugknbfddgicrmopn输出将是:dd但是,我尝试过类似的方法:re.findall('[a-z]{2}','ugknbfddgicrmopn')但在这种情况下,它会返回:['ug','kn','bf','dd','gi','cr','mo','pn']#theexceptoutputis`['dd']`我也有办法得到期望的输出:>>>l=[]>>>tmp=None>>>foriin'ugknbfddgicrmopn':...iftmp!=i:...tmp=i...cont

java.lang.RuntimeException : Performing stop of activity that is not resumed in android

我在一个项目上工作了几天并且工作正常。但是今天我在模拟器应用程序中运行我的应用程序,在启动屏幕上暂停而不进入主要Activity并且它显示错误:-执行停止不是恢复的Activity和ava.lang。RuntimeException:执行停止未恢复的Activity我的SplashScreen.java:-publicclassSplashScreenextendsAppCompatActivity{privatestaticintSPLASH_TIME_OUT=3000;Booleanflag=false;publicstaticActivityactivity_splash;@Ov

java : list that contains unique elements in order

java中是否有list类型以升序存储对象,如果之前添加了该对象,则不添加。我知道javamaps可以做到这一点,但我想知道是否有一个列表类型可以满足我的需求。否则我必须重写contains、equalsTo和add方法,对吗? 最佳答案 所以你需要一个只包含唯一元素的列表?两种选择:java.util.LinkedHashSet-保留插入顺序,具有集合语义来自commons-collectionsSetUniqueList-允许列表操作,如get(..)和set(..)来自commons-collectionsListOrdere

java - Maven + SLF4J : Version conflict when using two different dependencies that require two different SLF4J versions

我有一个项目独立使用这两个依赖项:BoneCP和Hibernate。但是由于SLF4J及其版本冲突,它不起作用,因为BoneCP需要SLF4J1.5而Hibernate需要SLF4j1.6。如您所知,不可能在pom.xml中对同一依赖项的两个不同版本进行重要处理。那么我能做些什么来解决这个惊人的SLF4J副作用???我得到的错误是臭名昭著的:SLF4J:Therequestedversion1.5.10byyourslf4jbindingisnotcompatiblewith[1.6]SLF4J:Seehttp://www.slf4j.org/codes.html#version_mi