Last active
February 11, 2020 14:32
-
-
Save prykon/72bc40fbcbcf0a1bb45c404ee7e49bed to your computer and use it in GitHub Desktop.
Graficador de Keyword Rankings para data extraída de Google Search Console con Google Data Studio.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
keywords = ['keyword 1', 'keyword 2', 'keyword 3'] #poné tus keywords acá | |
rank_limit = 30 #Cantidad de posiciones a analizar | |
#No hace falta modificar las siguientes líneas | |
df = pd.read_csv('data.csv') | |
df['Date'] = pd.to_datetime(df['Date'], format='%Y%m%d') | |
df = df[df['Query'].isin(keywords)].sort_values(by=['Date']) | |
df.set_index('Date', inplace=True) | |
df.groupby('Query')['Average Position'].plot(legend=True, figsize=(19.20,10.80)) | |
plt.gca().invert_yaxis() | |
plt.title('Keyword rankings\n') | |
plt.ylim(top=0.75, bottom=rank_limit) | |
plt.show() #comentá esta línea si estás trabajando con Jupyter Notebook | |
#Descomentá la siguiente línea para guardar el gráfico a un archivo | |
#plt.savefig('keywords_rankings.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Si querés ver el output como dataframe además del plot, agregá estas líneas al final del script...
Funciona mejor con una keyword a la vez.