Archive for May, 2016

May
02

Python vs. R

It is very difficult to say which one I like more.

Jupter vs. RMarkdown

  • RMarkDown: quick edit for beautiful report, compile is slow
  • Jupyter: console in web, flexible, but sometimes you will fall into chaos
  • Both can integrate different language

Speed:

  • Python > R

Community:

  • R has more users in no computer science community

Time Series:

  • R has very good tutorials and packages for time series.

Image processing:

  • Since Python is faster than R, Python is more suitable for image processing

Dataframe:

  • R: dplyr
  • Python: pandas

Conclusion:

Master the two languages, your will find many friends. 🙂

May
02

Install Jupyter Kernel

1. How to install ipython 3 kernel to jupyter?
+ install Anaconda 3
+ copy “Jupyter notebook” symbol to desktop
+ right click -> “property” -> “start in” change to the folder which you want to begin with

2. How to install IRKernel to Jupyter?
+ Open Anaconda 3 prompt
+ conda install -c r r-essentials
+ https://www.continuum.io/blog/developer/jupyter-and-conda-r

May
02

compare two lists

It is very easy to compare two lists in python, but it seems not so many people know it.

Just use the `==` symbol in numpy, it will return a numpy array with boolean value, True means the position are idential.

import numpy as np

aa = [“a”,”b”,”a”]
bb = [“b”,”b”,”a”]

np.array(aa)==np.array(bb)

>>array([False, True, True], dtype=bool)

see my example code in stackoverflow:

http://stackoverflow.com/a/36983379/3279996

May
02

break the long line in python

There are several methods to break the long string line in python. I think the triple-quoted “”” method is the easiest way. The reason is you can also for json object.

myJson =””” {
“result”:
[{“short_description”: “I am getting bluescreen error”,
“sys_id”: “39b5f8c2376ede007520021a54990e5c”,
“opened_at”: “2016-04-04 05:19:53”,
“number”:”INC0258523″
},
{
“short_description”: “laptop crashed with a blue screen”,
“sys_id”: “da0095380f43d200a4f941fce1050eeb”,
“opened_at”:”2016-04-25 06:33:52″,
“number”:”INC0259067″
},
{
“short_description”: “Laptop not booting”,
“sys_id”: “ecf9c9b00f43d200a4f941fce1050e17”,
“opened_at”: “2016-04-25 06:07:16”,
“number”: “INC0259061”
}]
}
“””
data = json.loads(myJson)

It works!