How to slice a list in Python

rdatacode provide affordable online training course for Python and R programming at fundamental level, click here for more details. Slicing a list in Python is a kind of operation that returns part of a list. The basic form of a slice is using starting and ending index with colon between of a list inside square brackets following a list. Say we have a list for family member, and will get part of a list from Read more…

Use str() to transform variable in Python

We provide affordable online training course for Python and R programming at fundamental level, click here for more details. In Python, if a string variable is concatenated with a numeric value directly, an error comes. In the following code example, a string variable ‘ strva’ is concatenated directly with number 2, Python returns a traceback, because these two data types can not be concatenated without transformation. To overcome this shortage, str() function can be applied Read more…

How to use arrange() function in R to sort dataset

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! arrange() function from Dplyr package in R provides an alternative way as sort() function in R base installation for sorting a data frame with respect to variables, either in ascending or descending order. Moreover, Dplyr is part of a bigger package framework called ‘tidyverse’, and it allows its functions to be chained using Read more…

How to use filter() function to select observations in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Dplyr is a package in R. It belongs to Tidyverse framework, and is allowed to use pipeline structure to chain multiple operations together into one statement. There are many functions in Dplyr package, and one of them is filter(). filter() is used to select observations in terms of specific conditions. For example we Read more…

Using get() method in Python to return value of the key in dictionary

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Python’s dictionary object type provides a function get() to return the value of the key in a dictionary. The difference between get() method and using bracket to index the key is that get() will return NULL in result when the key is not present, while the latter raises an error for nonexistent key. Read more…

Nesting dictionary in Python

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Dictionary in Python is a useful data object that stores key-value paired information. It can be nested, combined with lists or with dictionaries. In this post, we briefly introduce three nesting dictionary structures: dictionaries inside a list, lists inside a dictionary, and dictionaries inside a dictionary. The most useful case of this hierarchical Read more…

How to loop through a dictionary in Python

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Dictionary objects in Python make storing key-value pairs information fairly easy and straightforward. The information of the dictionary can be returned by using a for loop. There are usually three type of for loops mentioned with respect to the dictionary’s attributes: ‘items’ for getting key-value pairs, ‘keys’ for returning all the keys and Read more…

How to calculate binomial distribution in Python

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Binomial distribution in statistics is a type of discrete probability distribution, modeling the probability of success times among a predetermined Bernoulli process. A Bernoulli process is a binary experiment with result success or fail, in which the probability of success or fail is constant for each independent trial. The most striking point for Read more…

Tuple-Immutable list in Python

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Python object tuple is a type of list in which the elements can not be modified. It is immutable. When the elements are stored information that are stable, like the area of countries, values of genders, you can use tuples. Tuples are created using parentheses. In the following code, two tuples representing countries Read more…

List comprehension in Python

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! List comprehension is a concise way to create a list in Python. It is usually a composition of an expression with a for loop statement in the bracket. In the following code, we create a list of squared numbers using list comprehension. Here can we see element**2 is the expression. The later part Read more…