<jupyter_start><jupyter_text>SageMaker Notebook<jupyter_code># SELECT posts.title, comments.body ,comments.score
# FROM `fh-bigquery.reddit_comments.2019_*` AS comments
# JOIN `fh-bigquery.reddit_posts.2019_*`  AS posts
# ON posts.id = SUBSTR(comments.link_id, 4) 
# WHERE posts.subreddit = 'toastme' AND comments.score >= 1 AND posts.author != comments.author 
# AND comments.body != '[removed]' AND comments.body != '[deleted]' AND parent_id = link_id AND NOT REGEXP_CONTAINS(comments.body, r"\[[a-zA-Z0-9-]\]")



!pip3 install --upgrade six>=1.13.0


!pip install google-cloud-bigquery

import os
import json
import boto3
from google.cloud.bigquery import magics
from google.oauth2 import service_account
%load_ext google.cloud.bigquery
import os 
import boto3 
BUCKET = 'redcreds' 
KEY = 'My First Project-01f0de489aed.json' 
s3= boto3.resource('s3') 
s3.Bucket(BUCKET).download_file(KEY,'My First Project-01f0de489aed.json') 
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'My First Project-01f0de489aed.json'

%load_ext google.cloud.bigquery
%%bigquery df
SELECT *
FROM `toastme123.redditclean`

df.head()
# with open(writePath, 'a') as f:
#     f.write(df.to_string(header = False, index = False))
df = df.drop(['score','created_utc'], axis=1)
df['body'] = df.StringColumn.apply(lambda s: s+'XXX')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1400749063670412, 'fraction_numerical': 0.03445692883895131, 'mean_word_length': 5.58128078817734, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '424896', 'license': 'MIT', 'n_tokens_mistral': 525, 'n_tokens_neox': 498, 'n_words': 106, 'path': 'Notebooks/.ipynb_checkpoints/ToastMeDF-checkpoint.ipynb', 'repo_name': 'RahatDubey/gpt-2', 'size': '1335'}