geom_dotplot in rpy2? - python

When I try to use gplot2.geom_dotplot I get the error:
AttributeError: 'module' object has no attribute 'geom_dotplot'
Does this function have a different name in Rpy2? thanks.

The mapping of that function is just missing. This is a bug with rpy2. The fix will in the repository shortly (will be released with version 2.3.4).
In the meantime a workaround can be to add the following to your code.:
from rpy2.robjects.lib import ggplot2
class GeomDotplot(ggplot2.Geom):
_constructor = ggplot2.ggplot2_env['geom_dotplot']
ggplot2.geom_dotplot = GeomDotplot.new

Related

AttributeError: 'MainRouter' object has no attribute '_disabled_count'

I am creating a kivy app where I have used router showing this error-
AttributeError: 'MainRouter' object has no attribute '_disabled_count'
Any solution?
I got this too but fixed it using super. Call the default init from within your new init using
super().__init__(**kwargs)
This error is caused by Kivy version. The latest version of Kivy-1.10.1 has some bug which is causing the problem. The older version seems fine!

createDataFrame not working in Spark 2.0.0

I am trying to work through some of the examples in the new Spark 2.0 documentation. I am working in Jupyter Notebooks and command line. I can create a SparkSession with no problem. However when I try to create a dataframe I get the error of:
AttributeError: 'function' object has no attribute 'createDataFrame'
spark = SparkSession.builder.master("local").appName("Search").config(conf=SparkConf()).getOrCreate
d = [{'name': 'Alice', 'age': 1}]
spark.createDataFrame(d).collect()
Can someone please explain what I need to do to fix this error ? I have searched through the official documentation and not found anything on this particular error. Thank you.
getOrCreate is a method on SparkSession.Builder. You need to invoke it by adding the parentheses after:
spark = SparkSession.builder.master("local").appName("Search").config(conf=SparkConf()).getOrCreate()
See for more information: https://spark.apache.org/docs/2.0.1/api/java/org/apache/spark/sql/SparkSession.html
In general, the 'function' object has no attribute error is very common when you are accidentally referencing a function rather than invoking it.

Error with pickle module. AttributeError: class has no attribute '__new__'

I have been used python and Abaqus for a long time. But when i upgraded my python from 2.7 to 3.5.2 some error occures. I try to pickle some object A of my class.
f = open(utilsDir + "aclass.log", 'wb')
pickle.dump(A,f,protocol=2)
f.close()
and then unpickle it with abaqus' python, which is still 2.7.
filepath = utilsDir + 'aclass.log'
A1 = pickle.load(file(filepath))
All it has worked before updating my python, but now i have an error:
This is old and the answer will not help the OP, but in case anyone stumbles on this for a code he can modify, this error usually appears when the class pickled in Python 2 is not a new style class, i.e. does not inherit from object.

Bokeh plotting: 'NoneType' object has no attribute 'line'

I've just installed the latest version of Anaconda.
I am having a basic problem with Bokeh, from this example.
from bokeh.plotting import *
f = figure()
f.line(x, y)
AttributeError: 'NoneType' object has no attribute 'line'
I can plot by saying line(x,y), but it looks like the above method would provide more flexibility if it worked.
The example (and even the user guide) contradict the documentation for bokeh.plotting.figure(), which explicitly says it returns None, which explains the error you observe.
Using line() directly therefore seems to be the way to go.
However, this holds for bokeh versions before 0.7: version 0.7 deprecated implicit plotting. This means that figure().line() should work with bokeh 0.7+. The documentation for figure() has apparently not yet been updated.

AttributeError: 'ParentedTree' object has no attribute 'label'

I am basically working on parsed tree and trying to annotate tree nodes dominating empty categories(Empty node annotation).
I have defined a recurvsive function as below but the error that I am getting is "AttributeError: 'ParentedTree' object has no attribute 'label'".
def annotateTraceNodes(node):
numChildren = len(node);
numNone=0;
for child in node:
if isinstance(child,Tree):
annotateTraceNodes(child);
if(numChildren==0 or child.label().endswith("-NONE-")):
numNone+=1;
if(numChildren==numNone):
print "setting the label";
node.set_label(node.label()+"-NONE-");
Google suggests you're using NLTK, which I'm going to assume is the case.
A ParentedTree does not have a method called .label(). So when you write things like this:
child.label().endswith("-NONE-")
Python doesn't know what to do.
A Tree, on the other hand, does have a .label() method. Did you perhaps use a ParentedTree instead of a Tree somewhere?
Could also be a versioning issue.
Worked for me with version 3.3
pip install nltk==3.3

Categories