GOTOH Shunsuke
    • 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
    --- tags: LT, Python東海, Python slideOptions: transition: slide theme: league --- `np` とか `tf` とか `pd` とか `plt` とか === <!-- .element: style="font-size: 300%" --> 2019/06/01 Python東海 第39回勉強会 antimon2(後藤 俊介) Note: ごくごく Lite な Talk スライドですっ ---- ## お品書き + ~~お前誰よ?~~ 2つめなので略 + ~~Juliaの紹介~~ しません + `np` とか `tf` とか `pd` とか `plt` とか --- # `np` ---- ```python import numpy as np ``` <!-- .element: style="font-size: 150%" --> Note: `numpy` を `import` するときによく別名で `np` ってしますよねっ ---- ```python import numpy as np np.linalg.norm( np.random.rand(2).astype( np.float32)) ``` <!-- .element: style="font-size: 100%" --> Note: こんな感じによく書きますよねっ --- # `tf` ---- ```python import tensorflow as tf ``` <!-- .element: style="font-size: 150%" --> Note: `tensorflow` も `import` するときによく別名で `tf` ってしますよねっ ---- ```python import tensorflow as tf input_X = tf.placeholder(tf.float32, [None, M]) sess = tf.Session() ``` Note: こんな感じによく書きますよねっ --- # `pd` ---- ```python import pandas as pd ``` <!-- .element: style="font-size: 150%" --> Note: `pandas` を `import` するときによく別名で `pd` ってしますよねっ ---- ```python import pandas as pd pd.read_csv('/path/to/some_data.csv') ``` Note: こんな感じによく書きますよねっ --- # `plt` ---- ```python import matplotlib.pyplot as plt ``` <!-- .element: style="font-size: 100%" --> Note: `matplotlib.pyplot` を `import` するときによく別名で `plt` ってしますよねっ ---- ```python import matplotlib.pyplot as plt plt.plot(X, Y, label="hoge") ``` Note: こんな感じによく書きますよねっ --- # なんで? ---- ## なんで略語で <span>`import` するの?<!-- .element: style="white-space: nowrap"--></span> <!-- .element: style="font-size: 250%" --> ---- ![Pandas Tutorial より…](https://i.imgur.com/M6EWzPe.png) 《出展: [http://pandas.pydata.org/pandas-docs/stable/getting_started/10min.html](http://pandas.pydata.org/pandas-docs/stable/getting_started/10min.html) 》 <!-- .element: style="font-size:30%" --> ---- ![Cusomarily](https://i.imgur.com/LrNY3ns.png) ---- ## なんで <span>慣習化したの?<!-- .element: style="white-space: nowrap"--></span> <!-- .element: style="font-size: 250%" --> --- ![ボーッと生きてんじゃねーよ!](https://i.imgur.com/FTDAkXo.png) --- # PEP 221 ---- ## PEP 221 -\- Import As | … | … | | ------ | ----------- | |Author|thomas at python.org (Thomas Wouters)| |Status|Final| |Type|Standards Track| |Created|15-Aug-2000| |Python-Version|2.0| <!-- .element: style="font-size:90%" --> ---- [![PEP 221 -- Rationale](https://i.imgur.com/J4xb11I.png)](https://www.python.org/dev/peps/pep-0221/) Note: つまり「名前の衝突を防ぐため」が元々の目的? ---- [![PEP 221 -- Rationale (2)](https://i.imgur.com/Zeyq0yM.png)](https://www.python.org/dev/peps/pep-0221/) Note: キーワードじゃなければ名前に制限はない、からってその例… ---- [![1990年代後半〜 - 機械学習とPython - HackMD](https://i.imgur.com/NcJkoHg.jpg)](https://hackmd.io/p/HyIIR5bXm#/4/8) 《[機械学習とPython](https://hackmd.io/p/HyIIR5bXm) (Python東海 第36回勉強会 発表資料)より抜粋》 <!-- .element: style="font-size:30%" --> ---- + `import 〜 as 〜` が導入されたのが約20年前 + matplotlib/NumPy 等がその直後に公開 (Pandas は2011年) Note: ちなみにTensorFlowは2015年だからちょっと後 ---- ## もうお分かりですね? <!-- .element: style="font-size:360%" --> ---- + 公式が略語を例示 + `plt`/`np`/`pd` はそれに乗っかった + `tf` は `np` に引っ張られる形 <!-- .element: style="font-size:120%" --> ※私見です <!-- .element: class="fragment" style="text-align:right;font-size:60%" --> Note: 2〜3文字に略せば1行80文字以内に収まるしっ あとこれはあくまで私見ですっ --- # それで良いのか? ---- <blockquote class="twitter-tweet" data-lang="ja"><p lang="ja" dir="ltr">pandasにpd, numpyにnp など、慣習的に別名でインポートするモジュールがあるが、<br>①別名でインポートするか<br>②これについてどう思うか</p>&mdash; abap (@abap__) <a href="https://twitter.com/abap__/status/1124324227463520258?ref_src=twsrc%5Etfw">2019年5月3日</a></blockquote> <!--script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script--> Note: というアンケートがTwitterで展開されましたっ ---- ![投票結果](https://i.imgur.com/5i8Wdec.png) ---- + 7割以上の人が毒されている! + でも疑問に思っている人も一定数いる! <!-- .element: style="font-size:160%" --> ※私見です <!-- .element: class="fragment" style="text-align:right;font-size:60%" --> Note: 母数45人なのでまぁアレですが… --- # 今こそ全ての Pythonista に問います ---- ## あなたは `import 〜 as 〜` で 略語を使いますか? Note: それとも、`import` に `as` は使いませんか? --- ## 参考リンク + [PEP 221 -- Import As | Python.org](https://www.python.org/dev/peps/pep-0221/) --- ご清聴ありがとうございます。 Note: ご清聴ありがとうございますっ!

    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