Month: March 2019

It is quite rare for myself to have chance to read people Python’s code because none of my circle of friends are coding in Python. So I am not able to conclude how often people used the triple quotes (“””). Python allows single quotes and double quotes as well as triple quotes. While single and double quotes work similarly, triple quotes do something special.

The below is the extraction from my first Python’s blog entry.

We can use triple quotes (“””) for a string to span multiple lines and assign it to a variable. One of the examples I learned,

In the last few exercises in the Intermediate Python module in DataCamp, I learned how to do transpose on a Numpy array in Python. The code is simple and it handles by the Numpy package without hassle. Let us look into the code snippet below:

In one of my DataCamp’s exercise, it combines the randint() function from the Numpy package, the built-in max() function and matplotlib.pyplot package to do a simple visualization of random steps (random_walk) over 100 times with if-elif-else condition to increase or decrease the step’s value for each iteration. Then, it appends into the random_walk list to generate the line plot.

It returns values between 0 and 1, similar to the random() function above.

We can set a seed number where the same seed number will generate the same random number. This is useful because it ensures ‘reproducibility’ where it can be applied into running different versions of the same algorithm and you are using the exact same random numbers and making a fair comparison between the versions.

# Import numpy
import numpy as np
# Random rand() with seed
np.random.seed(10)
np.random.rand()
# This is different because we did not use seed
np.random.rand()

Using the randint()WIth Numpy randint(), we can specify the range of whole number to be randomly generated. The arguments for randint(),

numpy.random.randint(low, high=None, size=None, dtype=’l’)low: smallest signed numberhigh: optional. Largest signed number, but excluded from the random.size: optional. Output shape.dtype: optional. Desired dtype of the result.

I have covered the introduction of the Pandas and filtering in the Pandas DataFrame. Also, I covered the looping in Numpy array. In this entry, I continue sharing about looping, this time is looping in Pandas DataFrame.

In the example given by DataCamp, it reused the existing brics.csv file to explain. Let me include the screenshot of the DataFrame.

When we use a for loop to loop through the brics and print out the value, the output seems not what we want to see. Let see the example below:

The output of the print(brics) shows a new column, “name_length” is added into the DataFrame and the value is the length of the country’s name in the country column. See below for the captured screenshot:

In my exercise. I need to use a for loop to add a new column, named ‘COUNTRY’ that contains a uppercase version of the country names in the column ‘country’. My codes and the output of the execution as below:

It has been long time I did not visited Aston. I think the last vist was somewhere in late November last year to celebrate my aunt’s birthday at the Suntec City. This time I visited the branch at City Square, near Farrer Park MRT station.

The queue on Friday’s lunch on the day I visited the branch was quite long and it was quite crowded with working people, families and students as well.

It took us a while to come to our turn to place order at the counter before they lead us to our table. While waiting, I was unable to decide whether I want to eat the salmon with 2 side dishes or spaghetti with salmon. Then, I saw their new promotion, the chicken confit set which comes with 2 side dishes too. However, when it came to my turn to place order, the chicken confit was sold for the day. Wow!

So, I settled down with just the basic char-grilled chicken with garden veggie and potato wedges as my side dishes.

The char-grilled chicken completes with mushroom sauce on top of it makes my lunch so completed. The chicken chop is slightly over-grilled where I saw some burned bites. However, other part of the chicken meat is still tender and juicy.

The poached garden veggie is completely over-cooked until it is too soft for me. Probably, this is suitable for people who prefer to eat soft broccoli and carrot.

It was nicely presented in the takeaway box by the Deliveroo’s staff when my colleagues and myself dine-in the Deliveroo’s Kitchen at CT HUB 2, Lavender, Singapore. It comes with some chilies mixed fish sauce in a small container.

The amount of grilled chicken is very generous, definitely enough for you to go with the rice vermicelli and the meat is well cooked, just it looks a little bit dry and it is not oily.

The deep fried spring rolls are disappointed, why? When it means deep fried, I expected it to be less oily if the cook knows how to deep fried food. Maybe, deep fried spring rolls are different than other deep fried food? But hey, the amount of yellowish oils dripped down on to my plastic spoon is not healthy at all and it looks pretty disgusting. I have to use the table tissues to absorb all the excessive oils, or you may want to say (sauce!). I’m sure, not going to order this anymore. The deep fried spring rolls need improvement, or just serve it fresh.