Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Pandas - SciPy #3
Search
Vinicius Mesel (@vmesel)
October 14, 2016
Programming
94
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Pandas - SciPy #3
Vinicius Mesel (@vmesel)
October 14, 2016
More Decks by Vinicius Mesel (@vmesel)
See All by Vinicius Mesel (@vmesel)
Mas cadê as oportunidades Python?
vmesel
0
60
Iniciando em Machine Learning (com Python)
vmesel
0
710
Machine Learning: Os segredos deste setor!
vmesel
0
78
MicroPython e Sockets: Como interagir com os dois?
vmesel
0
75
Afinal, o que o Python achou do Impeachment?
vmesel
1
110
Other Decks in Programming
See All in Programming
App Intentsのビルドプロセスを支える技術
kntkymt
0
460
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
550
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
180
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
360
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.5k
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
230
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
300
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
210
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
18
18k
JRuby: Past, Present, and Future
headius
0
210
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
1k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Making the Leap to Tech Lead
cromwellryan
135
10k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
My Coaching Mixtape
mlcsv
0
330
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
570
The browser strikes back
jonoalderson
0
1.7k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
ラッコキーワード サービス紹介資料
rakko
1
5M
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Transcript
PANDAS Beatriz Uezu Marília Janizelli Marcelo Yamaki
None
para praticar pandas pragmaticamente por problemas percorreremos palanques, políticos pretensiosos,
partidos perversos...
Pergunta Qual a origem das receitas dos candidatos na corrida
eleitoral em SP e no RJ?
Só uma olhadinha na base de dados do TSE...
O arquivo possui 22 colunas e mais de 65 mil
linhas! Sim, pandinha, é demais! Para nos ajudar com a análise é importante uma pergunta: COMO ORGANIZAR OS DADOS?
import pandas as pd #importar Pandas import numpy as np
#importar numpy t = pd.read_excel('receitascandidatos1.xls',index_col=None, na_values=['NA']) #ler arquivo xls df = t[['UF'] + ['Nome candidato'] + ['Tipo receita'] + ['Valor receita']] #selecionar dados desejados uf = df[(df.UF.isin(['SP', 'RJ']))] #filtrar SP e RJ uf.groupby(['UF','Nome candidato', 'Tipo receita', 'Valor receita']).sum() #agrupar entradas tf = pd.pivot_table(uf,index=['UF','Nome candidato'], columns=['Tipo receita'], values='Valor receita', aggfunc=np.sum,fill_value=0) #reordenar dados tf.to_csv(‘file_name.csv’, encoding='utf-8') #salvar em arquivo CSV
O que estava nas linhas (Tipo da receita) se tornou
colunas com o uso do “pivot table”
Como era…. ...e como ficou após o pivot_table
Agora a análise dos dados reorganizados...
tf.info() <class 'pandas.core.frame.DataFrame'> MultiIndex: 8610 entries, (RJ, ABIEL CARVALHO DE
AQUINO) to (SP, ÍGOR VINICIUS RAMOS OLIVEIRA) Data columns (total 4 columns): Recursos de outros candidatos 8610 non-null float64 Recursos de partido político 8610 non-null float64 Recursos de pessoas físicas 8610 non-null float64 Recursos próprios 8610 non-null float64 dtypes: float64(4) memory usage: 336.3+ KB tf.head() tf.tail()
tf['Recursos de partido político'].hist() plt.show() Não dá pra ver...
tf['Recursos de partido político'].hist(bins=500) plt.show() Nada ainda...
tf['Recursos de partido político'].hist(range=[0,2000]) plt.show()
tf.describe() Tipo receita Recursos de outros candidatos Recursos de partido
político \ count 8610.000000 8610.000000 mean 286.581609 313.964129 std 1073.964616 2511.521873 min 0.000000 0.000000 25% 8.827500 0.000000 50% 142.200000 0.000000 75% 292.880000 72.500000 max 61309.500000 107248.760000 Tipo receita Recursos de pessoas físicas Recursos próprios count 8610.000000 8610.000000 mean 2.777294 0.621834 std 61.513543 26.299834 min 0.000000 0.000000 25% 0.000000 0.000000 50% 0.000000 0.000000 75% 0.000000 0.000000 max 3739.000000 2115.000000