alanhc
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # python [Jupyter nootbook 1](https://medium.com/python4u/jupyter-notebook%E5%AE%8C%E6%95%B4%E4%BB%8B%E7%B4%B9%E5%8F%8A%E5%AE%89%E8%A3%9D%E8%AA%AA%E6%98%8E-b8fcadba15f) [Jupyter nootbook 2](https://medium.com/jameslearningnote/%E8%B3%87%E6%96%99%E5%88%86%E6%9E%90-%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92-%E7%AC%AC1-2%E8%AC%9B-jupyter-notebook%E4%BB%8B%E7%B4%B9-705f023e3720) [ESC+H] 快速鍵 SHIFT+TAB 查詢函式用法 * [視覺化](https://nbviewer.jupyter.org/) [系列文章](https://ithelp.ithome.com.tw/articles/10192614) [Numpy](https://medium.com/python4u/hello-numpy-b5ebe67a1ada) [Jupter Notebook小提示](https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/451430/) pip3 install jupyter ## ananconda Q 怎麼用chrome開 ``` C:\Users\alant>jupyter notebook --generate-config Writing default config to: C:\Users\alant\.jupyter\jupyter_notebook_config.py 找到路徑 ``` import webbrowser webbrowser.register('chrome', None, webbrowser.GenericBrowser(u'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')) c.NotebookApp.browser = 'Chrome' ``` ## 操作csv import csv with open('C:/Users/alant/Desktop/sample.csv',mode='r', encoding='utf-8') as f: reader = csv.reader(f) for row in reader: print(row) ``` 從anaconda開 ### Python筆記 註解 ''' code ''' #code #### IO ```python print("hello") ``` #### 輸入 ```python usr_input=input() print(usr_input) ``` #### 迴圈 ```python for x in array: print(x) ``` #### 匯入 ```python import time print(time.localtime()) ``` #### List ```python list_data = [1,'string',3.1,[5,6,7]] print(list_data) ``` access list ```python print(list_data[3]) ``` list_data.append() list_data.remove() list_data.sort() #### 字典 宣告 ```python= dict={ 'key1':'val1','key1':'val2' } ``` 取值 ```python print(dict['key2']) ``` 列出 .keys() .values() #### 轉換型態 str(a) int(a) #### 機器學習重要函式 [數據分析的第一步](https://ithelp.ithome.com.tw/articles/10193295) Pandas * 以Numpy為基礎 * 整理數據表格 Numpy * 因大量數據list效能不好,有平行處理能力 * 矩陣基礎做數據的數學運算 Matplotlib * 畫圖 SciPy * 已Numpy為基礎 * 科學、工程的運算處理 ##### Pandas 資料類型 1. Series 基本語法: ```python= import pandas as pd my_obj = pd.Series([4, 7, -5, 3]) ``` 查看: .values .index 神奇index法 ```python my_obj2 = pd.Series([8,9,10,11], index=['a','b','c','d']) ``` dict轉換Series ```python dic_data = {'name':'apple','birthday':'1996-1-1','luckynumber':7 } my_obj3 = pd.Series(dic_data) ``` 2. DataFrame ```python import pandas as pd data = {'name': ['Bob', 'Nancy','Amy','Elsa','Jack'], 'year': [1996, 1997, 1997, 1996, 1997], 'month': [8, 8, 7, 1, 12], 'day':[11,23,8,3,11]} myframe = pd.DataFrame(data) myframe ``` 更改順序: 加上columns=[1,2,3] ex: pd.DataFrame(data,columns=['name','year', 'month', 'day']) 加入list ```python myframe2 = pd.DataFrame(data,columns=['name','year', 'month', 'day','luckynum']) luckynum = pd.Series([1,2,3]) myframe2['luckynum']=luckynum ``` * 讀取檔案 CSV pd.read_csv('PATH') 顯示頭三個 data = pd.read_csv('./data/sample.csv') data.head(3) .head() .tail() .info() 檔案資訊 .shape 表格資訊(row, columns) 存取 ```python data['年月'][0:4] 存取'年月'column 的 0~4 row ``` 存取多個column ```python data[['年月','上市股票-平均每股市值(元)']] ``` 新增aaa在column 3的位置,裡面值是hello ```python data.insert(3,column="aaa", value="hello") ``` 刪除NaN資料 nba = pd.read_csv('PATH') nba.dropna() 替代資料 nba = pd.read_csv('PATH') nba.fillna(0) 換成0 .sort_values("欄位") [0317學習 04:28](https://ithelp.ithome.com.tw/articles/10194003) 資料篩選 ```python import pandas as pd data = pd.read_csv('./data/sample.csv') mask = data["年月"] == 88 data[mask] 顯示 ``` isin([list]) .isnull() .notnull .between(88,90) 設定index 1. 第一種index_col ```python data = pd.read_csv('./data/sample.csv',index_col="年月") ``` 2. 第二種set_index ```python import pandas as pd data = pd.read_csv('./data/sample.csv') data.set_index('年月') ``` 取出index為某column的資料 ```python import pandas as pd data = pd.read_csv('./data/sample.csv') data.set_index('年月') data.loc[88] ``` 存取多個 data.loc[[88,89]] 依照index位置 > .iloc[0] 代表index 0 的位置資料 存取多個 .iloc[0:4] .iloc[[1,2,3]] 進階小用法 data.loc[88,'上市股票-本益比()'] 88年的上市股票本益比

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully