Posts

Showing posts with the label python_en

Pandas - make Data Frame as easy as R

Image
For a programming beginner,  one of the main difficulties is to transform or modify the raw data. Without the support of installed library, it is hard and time-consuming to handle this part. If you are the loyal R user, you should know that there is a special variable type: data frame. It is quite convenient to retrieve the attributes and corresponding values and further analysis. Thanks to Pandas package which is one of the modules in Python, we are allowed to analyze with the well-defined data structure. Let's install by inputting below command in CMD / terminal. Installation of Pandas Mac $ sudo pip install pandas Window > pip install pandas Ubuntu $ sudo apt-get install python-pandas Application Pandas also makes the procedures of reading file (.json, .csv, .html, etc.) simpler. The file with csv format is easier to handle since it has already been in the table-like structure. As a consequence I will take Json data as the example instead of .csv file. Refer to t...

Python - Data Processing with Dictionary

Image
This chapter is to share how to leverage the programming techniques to process the raw data more effectively. Please refer the previous articles to install the python, related modules and download the raw data in JSON format. In the previous examples, the age of 10 members are extracted and stored in an array. As we all know, there are 1 key(Member ID) and 3 attributes of a user(Name, Gender, Age). in the members' profile. Three lists/arrays needs to be declared and stored such information. > (name, gender, age, ...) = ([], [], [], ...) # multiple declare the arrays > for i in range(len(raw_data["profile"])):        name.append(raw_data["profile"][i]["name"])        gender.append(raw_data["profile"][i]["gender"])        age.append(raw_data["profile"][i]["age"]) Another way is that a dictionary with key value can be used to store the member list from JSON data. After that, summary st...

Python - Multi-Athlon Programming

Image
It is no doubt that Python can facilitates the development the tools with the support from the huge library. Many friends have raised a question which is better for data analysis with R or Python. Actually, there are CRAN in R and Python Package in Python, so that almost all function of R which Python also could have. As a both back-end developer and data analyst, Python seems to be the best choice of programming language for me to process the data extraction, preparation, analysis and modeling simultaneously. Download and Installation Steps to install the python for different kinds of OS are as follows. Installation of PIP which is used for downloading other useful modules is also include in the steps. Mac 1. Download the 2.7.x version in https://www.python.org/downloads/ 2. Open the downloaded file and follow the instruction to install the python 3. Run the python in terminals $ python >>> quit()      Quit the Python Shell 4. Open term...