# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/unburied/DiY-Help/blob/master/DiY_HelpSection_Eda.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="RBZZDXflq-pK" colab_type="code" colab={}
import pandas as pd

# + id="SuCuu0fa1AYk" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 228} outputId="5ca051ab-c0d0-4002-d0a2-6b827927ad47"
# !wget 'https://raw.githubusercontent.com/unburied/DiY-Help/master/Help%20Section%20Articles-February%2013%2C%202020%20(1).csv' 

# + id="2gu9Vc_-rZ57" colab_type="code" colab={}
# Load data and confirm shape equates to web scraped export
data ='Help Section Articles-February 13, 2020 (1).csv'
df = pd.read_csv(data)

assert df.shape == (427,4)

# + id="03jILfO-tpi0" colab_type="code" colab={}
import unicodedata as uc

# clean content data
def normaled_unicode(x):
  return uc.normalize('NFKD', str(x))
df['content'] = df.content.apply(normaled_unicode)

# get word count to output
def word_count(x):
  return len(x.split())
df['word_count'] = df.content.apply(word_count)

# + id="fJfYRYXb4SLM" colab_type="code" colab={}
VERBOSE = 75

result = df[df.word_count > VERBOSE]

# + id="rZxiQvMH5NQp" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 621} outputId="ced07c1e-e1cb-48c6-ea10-baf7604a6298"
result.tail()

# + id="x4RGsHrF8Ben" colab_type="code" colab={}
from datetime import date

today = date.today()
today = today.strftime("%B %d, %Y")

file_name = 'Word Counts' + today + '.csv'

result.to_csv(file_name, index = False)

# + id="fcJ-4wFP_HmA" colab_type="code" colab={}


StarcoderdataJupyterScriptsDedupFiltered