SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Downloaden Sie, um offline zu lesen
資料分析⽤用python
Honda @ Mosut
2014/05/31
Honda Dai
(aka Honda)
• 菸酒⽣生 @ 臺⼤大⼯工科所

intern @ KKBOX
Honda Dai
(aka Honda)
• 菸酒⽣生 @ 臺⼤大⼯工科所

intern @ KKBOX
• 喜歡 ruby <3
Honda Dai
(aka Honda)
• 菸酒⽣生 @ 臺⼤大⼯工科所

intern @ KKBOX
• 喜歡 ruby <3
謝謝⼩小鈞⼤大⼤大
謝謝⼩小鈞⼤大⼤大
每個禮拜
謝謝⼩小鈞⼤大⼤大
每個禮拜
都問我要不要來
MOSUT!!!
⽽而且⼀一拉就拉上台了 XD
所以我今天是來踢館的 (誤)
資料分析⽤用python
Honda @ Mosut
2014/05/31
資料分析⽤用python
Honda @ Mosut
2014/05/31
⽤用 Ruby 愛上 Python
⼤大家可能都知道
⼤大家可能都知道
Python是⼀一個很適合資料處
理的語⾔言
⼤大家可能都知道
Python是⼀一個很適合資料處
理的語⾔言
因為有⾮非常多好⽤用的⼯工具!
3rd libraries
3rd libraries
python:
3rd libraries
python:
numpy
3rd libraries
python:
numpy
scipy
3rd libraries
python:
numpy
scipy
matplotlib
3rd libraries
python:
numpy
scipy
matplotlib
etc…
3rd libraries
python:
numpy
scipy
matplotlib
3rd libraries
ruby:
3rd libraries
ruby:
…
3rd libraries
ruby:
…
…
3rd libraries
ruby:
…
…
sciruby
3rd libraries
ruby:
…
…
sciruby
Ruby has no equivalent to the beautifully constructed
numpy, scipy, and matplotlib libraries for Python
可是...
可是...
前⾯面的code都是 ruby 寫的...
可是...
前⾯面的code都是 ruby 寫的...
我不想砍掉重練啊!!
可是...
前⾯面的code都是 ruby 寫的...
我不想砍掉重練啊!!
⽽而且我就是想⽤用 ruby XD
Honored to Introduce…
Honored to Introduce…
RubyPython
RubyPython
• RubyPython is a bridge between the Ruby and
Python interpreters.
• It embeds a running Python interpreter in the Ruby
application's process using FFI and provides a
means for wrapping, converting, and calling Python
objects and methods.
- 官⽅方網站
簡單來說就是
• 在 Ruby 裏⾯面在插⼀一個 Python 的 interpreters
• 也就是說你必須要有 Python 的環境
• 會⾃自動將 Ruby 的 object 與 Python 的互相轉換
怎麼開始⽤用呢?
• gem install rubypython
• 確定你有 python
Live Demo
在 Ruby 內 call Python 的 method
踩雷時間
Q1: 我要 import 在 python 內⾃自⼰己安裝的 library,

為什麼會找不到 ?
• 觀察 Ruby 和 Python 底下的 sys.path,發現竟然不
⼀一樣多!
• Ruby
!
!
• Python
解決⽅方法
• 總之就是把 python 裡⾯面的 load_path 加進去就可以
了
!
• 結果:
ok!
Q2: 我想 call Python 的 method 並且指定參數,

為什麼失敗了?
Python:
Ruby:
Q2: 我想 call Python 的 method 並且指定參數,

為什麼失敗了?
Python:
Ruby:
我們的意思不是想把 a 變成這個.. XD
原因
• 這是 feature 不是 bug XD
• ⽽而且可能還會改
解決⽅方法
• 記得在那個 method 後⾯面加上 ! ,變成 method!
ok!
Q3: python 傳回的 tuple / array 在 ruby 內,

怎麼不能 multiple assign?
Python:
Ruby:
Q3: python 傳回的 tuple / array 在 ruby 內,

怎麼不能 multiple assign?
Python:
Ruby:
怎麼全都在 a 咧?
解決⽅方法
• ⽤用 to_a 把它變成 ruby 內的 array 物件就可以了
ok!
意猶未盡嗎?
意猶未盡嗎?
那再讓我講⼀一點 XD
Honored to Introduce…
MatPlotLib for Ruby
https://github.com/HondaDai/matplotlib-for-ruby
• 研究⽣生做模擬後總是需要跟⼀一堆數據打架
• 研究⽣生做模擬後總是需要跟⼀一堆數據打架
• Ruby 中實在沒有好⼯工具畫出美美的統計圖
• 研究⽣生做模擬後總是需要跟⼀一堆數據打架
• Ruby 中實在沒有好⼯工具畫出美美的統計圖
• 只好⾃自⼰己包⼀一個 :3
Live Demo
MatPlotLib for Ruby
結語
• 雖然⽅方便,但並不是⼀一個有效率的⽅方法
• 如果要⽤用在⼤大型專案上,可能要好好考慮
謝謝各位
Q&A

Más contenido relacionado

Empfohlen

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Rubypython - 用 ruby 愛上 python