Skip to content

Instantly share code, notes, and snippets.

@alexcombessie
Created February 6, 2019 16:53
Show Gist options
  • Save alexcombessie/d6d6c78af4ce4a2cbfe9c0a71088d119 to your computer and use it in GitHub Desktop.
Save alexcombessie/d6d6c78af4ce4a2cbfe9c0a71088d119 to your computer and use it in GitHub Desktop.
# -------------------------------------------------------------------------------- NOTEBOOK-CELL: CODE
# -*- coding: utf-8 -*-
import dataiku
import pandas as pd, numpy as np
import os
# Read recipe inputs
positive_python = dataiku.Dataset("positive_python")
df = positive_python.get_dataframe()
# Write recipe outputs
positive_python_folder = dataiku.Folder("positive_python_folder")
folder_path = positive_python_folder.get_path()
# -------------------------------------------------------------------------------- NOTEBOOK-CELL: CODE
# plotting libs
import wordcloud
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# -------------------------------------------------------------------------------- NOTEBOOK-CELL: CODE
## wordcloud creation
wc = wordcloud.WordCloud(
background_color='white',
max_font_size=40,
scale=3
).generate(str(df["tweet_simple"]))
fig = plt.figure()
plt.axis('off')
plt.imshow(wc)
plt.show()
# -------------------------------------------------------------------------------- NOTEBOOK-CELL: CODE
## save the wordcloud to the output folder
path_fig = folder_path + '/' + "wordcloud"
plt.savefig(path_fig)
# -------------------------------------------------------------------------------- NOTEBOOK-CELL: CODE
import dataiku.insights
id = "wordcloud_pos_python"
dataiku.insights.save_figure(id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment