Data visualization in Python (Coursera course)

イメージ
さて、pythonの方も最低1回/週ペースでは勉強していきたい。いや。行かねば。というこtで、 Courseraのコースを再検索。Python関連で興味の持てるコースとしては、 カリフォルニア大学が開いている、 The Raspberry Pi Platform and Python Programming for the Raspberry Pi というコースと、 IBMが主催している、 というコースがあった。で、どちらにしようかなーと思ったが、仕事でも役にたちそうで仕事で暇なときは仕事をしつつ勉強もできそうな Data Visualization with Pythonを受講することにしてみた。 Introduction のビデオを見てみたが、 Matplotlib, seaborn, folim といったライブラリを使って Dataの見えるかを行っていくようだ。 Week1の1st videも少し見てみた。知らなかったが、 Alberta大学の研究所からスピンアウトして設立したDARKHORSE analyticsという会社がデータの見えるかに関して良い仕事をしたらしい。 言いたいことをすぐにわかるようにするグラフを使おうということで、ごたごた飾り付けた3D Pie chartよりは、シンプルに言いたい部分だけ強調した bar chartが良いと。 ふむふむ。 なるほどね。。。。 もっと例が見たかったら,  http:///www.darkhorseanalytics.com/ へ行けと。。 いや。いいね。すごいね。見せ方が。 http://grades.dha.io/ https://www.darkhorseanalytics.com/portfolio/breathing-city こんな例もとても分かりやすい。分かりやすさがすごいね。 https://www.darkhorseanalytics.com/portfolio/2016/1/7/data-looks-better-naked-clear-off-the-table

Python

6月26日 火曜日
さて、もう 23時半で時間ないけど、Pythonの学習する。

プログラム言語も外国語も、毎日のように使っていないと忘れちゃうのでなるべく続ける。といいながら、木曜日夜から月曜日朝まで海外に友人の結婚式に参加するのでその間はさすがにやらないと思うけど。。

Courseraの2週目の課題を早めに終えられるように勧めていく。

Week2は List形式の勉強のようだ。

lis = ["a", "b", "c", "d", "e", "f"] の形ね。

あとは Datatypes
x = 17  #integer
y = 3.14 #float
z = "The Walrus" #string
z1 = "30" #string
vowels = {'a', 'e', 'i', 'o', 'u'] # list of strings
r = True # boolean
s = False #boolean

Datatype変換
numstr1 = input("Enter a number: ")
で、
num1 = float(numstr1)
で、変換とか。

この辺は言語でちょっと違うだけで超基本だな。
飛ばし気味に流す。。

あとは、sublist

newEngland = [["Massachusetts",6692824],["Connecticut",3596080],
              ["Maine",1328302],["New Hampshire",1323459],
              ["Rhode Island",1051511],["Vermont",626630]]

こんなの
newEngland[0] でとれば、["Massachusetts", 6692824] が取れる。
newEngland[1][0]でとれば、'Conneticut' がとれる。
newEngland[1][1]でとれば、3596080 がとれる。

あとは Random Library

import random で Random Libraryをimport

これで、 print (random.random()) とかで  0 - 1 までの乱数を出せる。
print (random.randint(3,8)) とかすると、 3 - 8 までの乱数を出せる。

リストからのランダム選択は
articles=["a", "the", "that", "this"]
article = random.choice(articles)

のような形でできると。。

最後に、Loops and Appendで、
break命令で while Loopから抜ける例とか

def add_up():
    sum_ = 0
    while True:             # will loop forever
        num = int(input("Enter a number, input 0 to quit: "))
        if num == 0:
            break           # breaks out of while loop
        sum_ = sum_ + num
    print(sum_)

List への 追加の append命令とか
num_lis.append(nextnum) で数字を追加。

2週目は大体こんなところか。

------------------
課題2:案外わからなかった(w)
最後の1個とるのはmy_list[-1]
途中から最後までは my_list[n:]
とか。

0) print the whole list (this doesn't require a while or for loop)
1) print the item with index 0
2) print the last item in the list
3) print the items with indexes 3 through 5 but not including 5
4) print the items up to the one with index 3 but not including item 3
5) print the items starting at index 3 and going through the end.
6) print the length of the list ( use len() )
7) Use the append() method of a list to append the letter "z" onto a list.
   Print the list with z appended.

def problem2_2(my_list):
    print(my_list)
    print(my_list[0])
    print(my_list[-1])
    print(my_list[3:5])
    print(my_list[0:3])
    print(my_list[3:])
    print(len(my_list))
    my_list.append("z")
    print(my_list)
------------------------------------------

もう1時か:寝よう。
Problem 2_2 まで。
problem 2_8まである。
明日どこかで策っと終わらせて提出しとかないと提出する日がない。

コメント

このブログの人気の投稿

Python_programming (Coursera)

7/22 再開再開。。

Data visualization in Python (Coursera course)