Posts

Showing posts from 2019

[DataCamp] SOA on Python Data Science Toolbox (Part2)

Image
Main contents of this course are as follows 1. Iterators, Iterables in Detail 2. enumerate(), zip(), unzip() and using * on iterators 3. using iterators to load large files into memory 4. List comprehensions, nested list, conditionals in comprehensions 5. generators, generator expressions 6. generators, iterators for streaming data 7. iterators to load data in chunks

[DataCamp] SOA on Python Data Science Toolbox (Part1)

Image
This course was NOT as good as previous courses. Some functions and keywords, which are new, are not explained in detail before problems are suggested. However, this courses are still very good to me so far. Main contents of this course are as follows 1. Making user defined functions 2. Variable-length arguments and Nested functions 3. Lambda functions and map(), filter(), reduce() 4. Error Handling : try-except, raise

[Python] Code Example 6 - Lambda & filter function (2)

[Source Code] # Select retweets from the Twitter DataFrame: result result = filter(lambda x : x[0:2] == 'RT', tweets_df['text']) # Create list from filter object result: res_list res_list = list(result) # Print all retweets in res_list for tweet in res_list:     print(tweet) [Output] ========================================== <script.py> output:     RT @bpolitics: .@krollbondrating's Christopher Whalen says Clinton is the weakest Dem candidate in 50 years https://t.co/pLk7rvoRSn https:/…     RT @HeidiAlpine: @dmartosko Cruz video found.....racing from the scene.... #cruzsexscandal https://t.co/zuAPZfQDk3     RT @AlanLohner: The anti-American D.C. elites despise Trump for his America-first foreign policy. Trump threatens their gravy train. https:…     RT @BIackPplTweets: Young Donald trump meets his neighbor  https://t.co/RFlu17Z1eE     RT @trumpresearch: @WaitingInBagd...

[Python] Code Example 5 - Lambda & filter function (1)

[Source Code] # Create a list of strings: fellowship fellowship = ['frodo', 'samwise', 'merry', 'pippin', 'aragorn', 'boromir', 'legolas', 'gimli', 'gandalf'] # Use filter() to apply a lambda function over fellowship: result result = filter(lambda member: len(member) > 6, fellowship) # Convert result to a list: result_list result_list = list(result) # Print result_list print(result_list) [Output] ========================================== ['samwise', 'aragorn', 'boromir', 'legolas', 'gandalf']

In a tiny sand island in Maldives (Feb, 2019)

Image
Never thought I could capture this scenery like I was in Bahamas. The color of this moment was exactly the same as one seen in Bahamas. Sometimes we recover our exhausted lives just by watching a moment of our memories.

[DataCamp] SOA on Intermediate Python for Data Science

Image
Interesting. This interactive course demands detailed manual coding(typing) and also focuses on important points of Python coding with considerate video lessons. I'll continue to complete these courses. These programs inspire me, and show me some other insights.

[Python] Code Example 4 - Manipulating DataFrame (Add column)

[Source Code] # Import cars data import pandas as pd cars = pd.read_csv('cars.csv', index_col = 0) # Use .apply(str.upper) cars["COUNTRY"] = cars["country"].apply(str.upper) print(cars) [Output] ========================================== <script.py> output:          cars_per_cap        country  drives_right        COUNTRY     US            809  United States          True  UNITED STATES     AUS           731      Australia         False      AUSTRALIA     JAP           588          Japan         False          JAPAN     IN             18        ...

[Python] Code Example 3 - Filtering Pandas DataFrame

[Source Code] # Import cars data import pandas as pd cars = pd.read_csv('cars.csv', index_col = 0) # Import numpy, you'll need this import numpy as np # Create medium: observations with cars_per_cap between 100 and 500 cpc = cars['cars_per_cap'] between = np.logical_and(cpc > 100, cpc < 500) medium = cars[between] # Print medium print(medium) [Output] ==========================================     cars_per_cap country  drives_right RU           200  Russia          True [Reference] ======================================== In [2]: cars Out[2]:       cars_per_cap        country  drives_right US            809  United States          True AUS           731      Australia         False JAP    ...

[Python] Code Example 2 - CSV to DataFrame

[Source Code] # Import pandas as pd import pandas as pd # Fix import by including index_col cars = pd.read_csv('cars.csv', index_col = 0) # Print out cars print(cars) [Output] ==========================================      cars_per_cap        country  drives_right US            809  United States          True AUS           731      Australia         False JAP           588          Japan         False IN             18          India         False RU            200         Russia          True MOR            70    ...

[Python] Code Example 1 - Dictionary

[Source Code] import pandas as pd # Build cars DataFrame names = ['United States', 'Australia', 'Japan', 'India', 'Russia', 'Morocco', 'Egypt'] dr =  [True, False, False, False, True, True, True] cpc = [809, 731, 588, 18, 200, 70, 45] dict = { 'country':names, 'drives_right':dr, 'cars_per_cap':cpc } cars = pd.DataFrame(dict) print(cars) # Definition of row_labels row_labels = ['US', 'AUS', 'JAP', 'IN', 'RU', 'MOR', 'EG'] # Specify row labels of cars cars = pd.DataFrame(dict, row_labels) # Print cars again print(cars) [Output]==========================================        cars_per_cap        country  drives_right     0           809  United States          True     1           731      Australia         False     2          ...

The First Accomplishment on DataCamp Learning

Image
Do you know that Microsoft supports DataCamp Learning for 2 month free subscription? Recently, I found this program. ( See More ) As a shareholder, I wanted to analyze detailed policies of Microsoft company ( MSFT ) . Anyway, DataCamp is one of on-line education sites, such as Coursera, and it is clearly optimized for learning R and Python. It gives you Interactive User Interface for easy learning R / Python. Several years ago, I used Python for a while to calculate a bunch of data, and thought this language was simple but cannot be alternative choice because of R. Python has adopted so many "imports" as simple/powerful libraries. Now, it's very easy to use, and efficient in analyzing huge data on and off the Internet. If you want to learn R or Python, I recommend you to register Free Microsoft Account for Free subscription on DataCamp for 2 months.