eval Function
The eval() function evaluates the specified expression (code), and runs it. The syntax is as below
Here, we gather concise notes.
The eval() function evaluates the specified expression (code), and runs it. The syntax is as below
If you want to handle a global variable in an imported module, simply add it to the builtin module. Let's assume that VAR is a global variable in the fun1 function within the test module:
If you need to create the variable name using the loop object, use exec.
Using df.apply(fun) can apply a function on columns or row:
Here and a brief of Useful functions of python core, Numpy and Panda are presented.
To show how generate the cross tabulate, let us categorize the columns; consider two continuous variables ( e.g., housing_median_age and total_rooms), categorize them according their .3 and .7 quantiles, and label the elements as L, M, and H. Then find the cross tabulate of them,
The value True (T) and False (F) are referred to as logical values and used the same in Python; their corresponding values are 1 and 0. Run the following codes and explains what the codes do.
Data-frame via pandas is very useful format for working with dataset, its structure is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). The following codes create a data-frame from a dictionary.