How to install a newer version of Python using apt-get?

Published on

How to install a newer version of Python using apt-get? Felix Krull runs a PPA offering basically any version of Python (seriously, there is 2.3.7 build for vivid…) for many Ubuntu releases at https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes. Do the usual: sudo add-apt-repository ppa:fkrull/deadsnakes sudo apt-get update sudo apt-get install python3.5 It will not overwrite your existing python3.4 which … Continue reading How to install a newer version of Python using apt-get?

How to convert categorical data to numerical data in Pyspark

Published on

How to convert categorical data to numerical data in Pyspark This can be done using StringIndexer in PySpark and the reverse using IndexToString for reference please check this: from pyspark.ml.feature import StringIndexer df = sqlContext.createDataFrame( [(0, “a”), (1, “b”), (2, “c”), (3, “a”), (4, “a”), (5, “c”)], [“id”, “category”]) indexer = StringIndexer(inputCol=”category”, outputCol=”categoryIndex”) indexed = … Continue reading How to convert categorical data to numerical data in Pyspark

How to run Python on Android?

Published on

Run Python on Android One way is to use Kivy: Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. Kivy runs on Linux, Windows, OS X, Android and iOS. You can run the same code on all supported platforms. Kivy Showcase app ———————————————-/OR/—————————————————— An … Continue reading How to run Python on Android?

Difference between @staticmethod and @classmethod in Python?

Published on

Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_fooand static_foo: class A(object): def foo(self,x): print “executing foo(%s,%s)”%(self,x) @classmethod def class_foo(cls,x): print “executing class_foo(%s,%s)”%(cls,x) @staticmethod def static_foo(x): print “executing static_foo(%s)”%x a=A() Below is the usual way an object instance calls a method. The object instance, a, is … Continue reading Difference between @staticmethod and @classmethod in Python?