Datasets:
EricR401S
commited on
Commit
•
50088f9
1
Parent(s):
de05476
first function complete
Browse files- reddit_dataset_loader.py +47 -37
- reddit_posts_fm.csv +0 -0
- reddit_scraping_nb.ipynb +505 -1
reddit_dataset_loader.py
CHANGED
@@ -94,43 +94,53 @@ class SubRedditPosts(datasets.GeneratorBasedBuilder):
|
|
94 |
|
95 |
DEFAULT_CONFIG_NAME = "first_domain" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
# def _split_generators(self, dl_manager):
|
136 |
# # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
|
|
94 |
|
95 |
DEFAULT_CONFIG_NAME = "first_domain" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
96 |
|
97 |
+
def _info(self):
|
98 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
99 |
+
if (
|
100 |
+
self.config.name == "first_domain"
|
101 |
+
): # This is the name of the configuration selected in BUILDER_CONFIGS above
|
102 |
+
features = datasets.Features(
|
103 |
+
{
|
104 |
+
"subreddit": datasets.Value("string"),
|
105 |
+
"id": datasets.Value("string"),
|
106 |
+
"title": datasets.Value("string"),
|
107 |
+
"text": datasets.Value("string"),
|
108 |
+
"url": datasets.Value("string"),
|
109 |
+
"score": datasets.Value("int64"),
|
110 |
+
"author": datasets.Value("string"),
|
111 |
+
"date": datasets.Value("string"),
|
112 |
+
# These are the features of your dataset like images, labels ...
|
113 |
+
}
|
114 |
+
)
|
115 |
+
else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
116 |
+
features = datasets.Features(
|
117 |
+
{
|
118 |
+
"subreddit": datasets.Value("string"),
|
119 |
+
"id": datasets.Value("string"),
|
120 |
+
"title": datasets.Value("string"),
|
121 |
+
"text": datasets.Value("string"),
|
122 |
+
"url": datasets.Value("string"),
|
123 |
+
"score": datasets.Value("int64"),
|
124 |
+
"author": datasets.Value("string"),
|
125 |
+
"date": datasets.Value("string"),
|
126 |
+
# These are the features of your dataset like images, labels ...
|
127 |
+
}
|
128 |
+
)
|
129 |
+
return datasets.DatasetInfo(
|
130 |
+
# This is the description that will appear on the datasets page.
|
131 |
+
description=_DESCRIPTION,
|
132 |
+
# This defines the different columns of the dataset and their types
|
133 |
+
features=features, # Here we define them above because they are different between the two configurations
|
134 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
135 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
136 |
+
# supervised_keys=("sentence", "label"),
|
137 |
+
# Homepage of the dataset for documentation
|
138 |
+
homepage=_HOMEPAGE,
|
139 |
+
# License for the dataset if available
|
140 |
+
license=_LICENSE,
|
141 |
+
# Citation for the dataset
|
142 |
+
citation=_CITATION,
|
143 |
+
)
|
144 |
|
145 |
# def _split_generators(self, dl_manager):
|
146 |
# # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
reddit_posts_fm.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
reddit_scraping_nb.ipynb
CHANGED
@@ -8904,6 +8904,510 @@
|
|
8904 |
" f.write(line + \"\\n\")"
|
8905 |
]
|
8906 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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": "3.
|
8932 |
}
|
8933 |
},
|
8934 |
"nbformat": 4,
|
|
|
8904 |
" f.write(line + \"\\n\")"
|
8905 |
]
|
8906 |
},
|
8907 |
+
{
|
8908 |
+
"cell_type": "code",
|
8909 |
+
"execution_count": 3,
|
8910 |
+
"metadata": {},
|
8911 |
+
"outputs": [],
|
8912 |
+
"source": [
|
8913 |
+
"# load the csv and check it\n",
|
8914 |
+
"df = pd.read_csv(\"reddit_posts_fm.csv\")"
|
8915 |
+
]
|
8916 |
+
},
|
8917 |
+
{
|
8918 |
+
"cell_type": "code",
|
8919 |
+
"execution_count": 7,
|
8920 |
+
"metadata": {},
|
8921 |
+
"outputs": [
|
8922 |
+
{
|
8923 |
+
"data": {
|
8924 |
+
"text/plain": [
|
8925 |
+
"subreddit object\n",
|
8926 |
+
"id object\n",
|
8927 |
+
"title object\n",
|
8928 |
+
"text object\n",
|
8929 |
+
"url object\n",
|
8930 |
+
"score int64\n",
|
8931 |
+
"author object\n",
|
8932 |
+
"date float64\n",
|
8933 |
+
"dtype: object"
|
8934 |
+
]
|
8935 |
+
},
|
8936 |
+
"execution_count": 7,
|
8937 |
+
"metadata": {},
|
8938 |
+
"output_type": "execute_result"
|
8939 |
+
}
|
8940 |
+
],
|
8941 |
+
"source": [
|
8942 |
+
"df.dtypes"
|
8943 |
+
]
|
8944 |
+
},
|
8945 |
+
{
|
8946 |
+
"cell_type": "code",
|
8947 |
+
"execution_count": 8,
|
8948 |
+
"metadata": {},
|
8949 |
+
"outputs": [
|
8950 |
+
{
|
8951 |
+
"data": {
|
8952 |
+
"text/html": [
|
8953 |
+
"<div>\n",
|
8954 |
+
"<style scoped>\n",
|
8955 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
8956 |
+
" vertical-align: middle;\n",
|
8957 |
+
" }\n",
|
8958 |
+
"\n",
|
8959 |
+
" .dataframe tbody tr th {\n",
|
8960 |
+
" vertical-align: top;\n",
|
8961 |
+
" }\n",
|
8962 |
+
"\n",
|
8963 |
+
" .dataframe thead th {\n",
|
8964 |
+
" text-align: right;\n",
|
8965 |
+
" }\n",
|
8966 |
+
"</style>\n",
|
8967 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
8968 |
+
" <thead>\n",
|
8969 |
+
" <tr style=\"text-align: right;\">\n",
|
8970 |
+
" <th></th>\n",
|
8971 |
+
" <th>subreddit</th>\n",
|
8972 |
+
" <th>id</th>\n",
|
8973 |
+
" <th>title</th>\n",
|
8974 |
+
" <th>text</th>\n",
|
8975 |
+
" <th>url</th>\n",
|
8976 |
+
" <th>score</th>\n",
|
8977 |
+
" <th>author</th>\n",
|
8978 |
+
" <th>date</th>\n",
|
8979 |
+
" </tr>\n",
|
8980 |
+
" </thead>\n",
|
8981 |
+
" <tbody>\n",
|
8982 |
+
" <tr>\n",
|
8983 |
+
" <th>0</th>\n",
|
8984 |
+
" <td>theredpillrebooted</td>\n",
|
8985 |
+
" <td>17c1wxt</td>\n",
|
8986 |
+
" <td>My name is Benjamin Persits and I am so sick o...</td>\n",
|
8987 |
+
" <td>Yes, I'm using my full name because I'm so sic...</td>\n",
|
8988 |
+
" <td>NaN</td>\n",
|
8989 |
+
" <td>0</td>\n",
|
8990 |
+
" <td>benjypersits</td>\n",
|
8991 |
+
" <td>1.697773e+09</td>\n",
|
8992 |
+
" </tr>\n",
|
8993 |
+
" <tr>\n",
|
8994 |
+
" <th>1</th>\n",
|
8995 |
+
" <td>theredpillrebooted</td>\n",
|
8996 |
+
" <td>16i06xc</td>\n",
|
8997 |
+
" <td>WHAT THE FUCK!?!?!?!?</td>\n",
|
8998 |
+
" <td>NaN</td>\n",
|
8999 |
+
" <td>https://v.redd.it/8d1eapsih3ob1</td>\n",
|
9000 |
+
" <td>0</td>\n",
|
9001 |
+
" <td>PatchesTheIdiot</td>\n",
|
9002 |
+
" <td>1.694642e+09</td>\n",
|
9003 |
+
" </tr>\n",
|
9004 |
+
" <tr>\n",
|
9005 |
+
" <th>2</th>\n",
|
9006 |
+
" <td>theredpillrebooted</td>\n",
|
9007 |
+
" <td>16a4ekb</td>\n",
|
9008 |
+
" <td>Why is she an asshole with me and how to handl...</td>\n",
|
9009 |
+
" <td>So I got this girl who's kinda my crush but I ...</td>\n",
|
9010 |
+
" <td>NaN</td>\n",
|
9011 |
+
" <td>0</td>\n",
|
9012 |
+
" <td>Worried-Horse-3408</td>\n",
|
9013 |
+
" <td>1.693862e+09</td>\n",
|
9014 |
+
" </tr>\n",
|
9015 |
+
" <tr>\n",
|
9016 |
+
" <th>3</th>\n",
|
9017 |
+
" <td>theredpillrebooted</td>\n",
|
9018 |
+
" <td>15f45sl</td>\n",
|
9019 |
+
" <td>Popular US vlogger Gonzalo Lira aka Coach Red ...</td>\n",
|
9020 |
+
" <td>&amp;#x200B;\\n\\n[https://chng.it/gFyFvqS5K7](h...</td>\n",
|
9021 |
+
" <td>NaN</td>\n",
|
9022 |
+
" <td>0</td>\n",
|
9023 |
+
" <td>Beautiful_Diamond980</td>\n",
|
9024 |
+
" <td>1.690871e+09</td>\n",
|
9025 |
+
" </tr>\n",
|
9026 |
+
" <tr>\n",
|
9027 |
+
" <th>4</th>\n",
|
9028 |
+
" <td>theredpillrebooted</td>\n",
|
9029 |
+
" <td>12wwyzc</td>\n",
|
9030 |
+
" <td>Mrs. Rooster by Stinky Buckets</td>\n",
|
9031 |
+
" <td>NaN</td>\n",
|
9032 |
+
" <td>https://youtube.com/watch?v=jK5BQngWne4&amp;fe...</td>\n",
|
9033 |
+
" <td>1</td>\n",
|
9034 |
+
" <td>LetsGoRedDevils</td>\n",
|
9035 |
+
" <td>1.682297e+09</td>\n",
|
9036 |
+
" </tr>\n",
|
9037 |
+
" </tbody>\n",
|
9038 |
+
"</table>\n",
|
9039 |
+
"</div>"
|
9040 |
+
],
|
9041 |
+
"text/plain": [
|
9042 |
+
" subreddit id \\\n",
|
9043 |
+
"0 theredpillrebooted 17c1wxt \n",
|
9044 |
+
"1 theredpillrebooted 16i06xc \n",
|
9045 |
+
"2 theredpillrebooted 16a4ekb \n",
|
9046 |
+
"3 theredpillrebooted 15f45sl \n",
|
9047 |
+
"4 theredpillrebooted 12wwyzc \n",
|
9048 |
+
"\n",
|
9049 |
+
" title \\\n",
|
9050 |
+
"0 My name is Benjamin Persits and I am so sick o... \n",
|
9051 |
+
"1 WHAT THE FUCK!?!?!?!? \n",
|
9052 |
+
"2 Why is she an asshole with me and how to handl... \n",
|
9053 |
+
"3 Popular US vlogger Gonzalo Lira aka Coach Red ... \n",
|
9054 |
+
"4 Mrs. Rooster by Stinky Buckets \n",
|
9055 |
+
"\n",
|
9056 |
+
" text \\\n",
|
9057 |
+
"0 Yes, I'm using my full name because I'm so sic... \n",
|
9058 |
+
"1 NaN \n",
|
9059 |
+
"2 So I got this girl who's kinda my crush but I ... \n",
|
9060 |
+
"3 &#x200B;\\n\\n[https://chng.it/gFyFvqS5K7](h... \n",
|
9061 |
+
"4 NaN \n",
|
9062 |
+
"\n",
|
9063 |
+
" url score \\\n",
|
9064 |
+
"0 NaN 0 \n",
|
9065 |
+
"1 https://v.redd.it/8d1eapsih3ob1 0 \n",
|
9066 |
+
"2 NaN 0 \n",
|
9067 |
+
"3 NaN 0 \n",
|
9068 |
+
"4 https://youtube.com/watch?v=jK5BQngWne4&fe... 1 \n",
|
9069 |
+
"\n",
|
9070 |
+
" author date \n",
|
9071 |
+
"0 benjypersits 1.697773e+09 \n",
|
9072 |
+
"1 PatchesTheIdiot 1.694642e+09 \n",
|
9073 |
+
"2 Worried-Horse-3408 1.693862e+09 \n",
|
9074 |
+
"3 Beautiful_Diamond980 1.690871e+09 \n",
|
9075 |
+
"4 LetsGoRedDevils 1.682297e+09 "
|
9076 |
+
]
|
9077 |
+
},
|
9078 |
+
"execution_count": 8,
|
9079 |
+
"metadata": {},
|
9080 |
+
"output_type": "execute_result"
|
9081 |
+
}
|
9082 |
+
],
|
9083 |
+
"source": [
|
9084 |
+
"df.head()"
|
9085 |
+
]
|
9086 |
+
},
|
9087 |
+
{
|
9088 |
+
"cell_type": "code",
|
9089 |
+
"execution_count": 11,
|
9090 |
+
"metadata": {},
|
9091 |
+
"outputs": [
|
9092 |
+
{
|
9093 |
+
"data": {
|
9094 |
+
"text/html": [
|
9095 |
+
"<div>\n",
|
9096 |
+
"<style scoped>\n",
|
9097 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
9098 |
+
" vertical-align: middle;\n",
|
9099 |
+
" }\n",
|
9100 |
+
"\n",
|
9101 |
+
" .dataframe tbody tr th {\n",
|
9102 |
+
" vertical-align: top;\n",
|
9103 |
+
" }\n",
|
9104 |
+
"\n",
|
9105 |
+
" .dataframe thead th {\n",
|
9106 |
+
" text-align: right;\n",
|
9107 |
+
" }\n",
|
9108 |
+
"</style>\n",
|
9109 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
9110 |
+
" <thead>\n",
|
9111 |
+
" <tr style=\"text-align: right;\">\n",
|
9112 |
+
" <th></th>\n",
|
9113 |
+
" <th>subreddit</th>\n",
|
9114 |
+
" <th>id</th>\n",
|
9115 |
+
" <th>title</th>\n",
|
9116 |
+
" <th>text</th>\n",
|
9117 |
+
" <th>url</th>\n",
|
9118 |
+
" <th>score</th>\n",
|
9119 |
+
" <th>author</th>\n",
|
9120 |
+
" <th>date</th>\n",
|
9121 |
+
" </tr>\n",
|
9122 |
+
" </thead>\n",
|
9123 |
+
" <tbody>\n",
|
9124 |
+
" <tr>\n",
|
9125 |
+
" <th>0</th>\n",
|
9126 |
+
" <td>theredpillrebooted</td>\n",
|
9127 |
+
" <td>17c1wxt</td>\n",
|
9128 |
+
" <td>My name is Benjamin Persits and I am so sick o...</td>\n",
|
9129 |
+
" <td>Yes, I'm using my full name because I'm so sic...</td>\n",
|
9130 |
+
" <td>NaN</td>\n",
|
9131 |
+
" <td>0</td>\n",
|
9132 |
+
" <td>benjypersits</td>\n",
|
9133 |
+
" <td>2023-10-20 03:40:33</td>\n",
|
9134 |
+
" </tr>\n",
|
9135 |
+
" <tr>\n",
|
9136 |
+
" <th>1</th>\n",
|
9137 |
+
" <td>theredpillrebooted</td>\n",
|
9138 |
+
" <td>16i06xc</td>\n",
|
9139 |
+
" <td>WHAT THE FUCK!?!?!?!?</td>\n",
|
9140 |
+
" <td>NaN</td>\n",
|
9141 |
+
" <td>https://v.redd.it/8d1eapsih3ob1</td>\n",
|
9142 |
+
" <td>0</td>\n",
|
9143 |
+
" <td>PatchesTheIdiot</td>\n",
|
9144 |
+
" <td>2023-09-13 21:57:56</td>\n",
|
9145 |
+
" </tr>\n",
|
9146 |
+
" <tr>\n",
|
9147 |
+
" <th>2</th>\n",
|
9148 |
+
" <td>theredpillrebooted</td>\n",
|
9149 |
+
" <td>16a4ekb</td>\n",
|
9150 |
+
" <td>Why is she an asshole with me and how to handl...</td>\n",
|
9151 |
+
" <td>So I got this girl who's kinda my crush but I ...</td>\n",
|
9152 |
+
" <td>NaN</td>\n",
|
9153 |
+
" <td>0</td>\n",
|
9154 |
+
" <td>Worried-Horse-3408</td>\n",
|
9155 |
+
" <td>2023-09-04 21:19:27</td>\n",
|
9156 |
+
" </tr>\n",
|
9157 |
+
" <tr>\n",
|
9158 |
+
" <th>3</th>\n",
|
9159 |
+
" <td>theredpillrebooted</td>\n",
|
9160 |
+
" <td>15f45sl</td>\n",
|
9161 |
+
" <td>Popular US vlogger Gonzalo Lira aka Coach Red ...</td>\n",
|
9162 |
+
" <td>&amp;#x200B;\\n\\n[https://chng.it/gFyFvqS5K7](h...</td>\n",
|
9163 |
+
" <td>NaN</td>\n",
|
9164 |
+
" <td>0</td>\n",
|
9165 |
+
" <td>Beautiful_Diamond980</td>\n",
|
9166 |
+
" <td>2023-08-01 06:21:36</td>\n",
|
9167 |
+
" </tr>\n",
|
9168 |
+
" <tr>\n",
|
9169 |
+
" <th>4</th>\n",
|
9170 |
+
" <td>theredpillrebooted</td>\n",
|
9171 |
+
" <td>12wwyzc</td>\n",
|
9172 |
+
" <td>Mrs. Rooster by Stinky Buckets</td>\n",
|
9173 |
+
" <td>NaN</td>\n",
|
9174 |
+
" <td>https://youtube.com/watch?v=jK5BQngWne4&amp;fe...</td>\n",
|
9175 |
+
" <td>1</td>\n",
|
9176 |
+
" <td>LetsGoRedDevils</td>\n",
|
9177 |
+
" <td>2023-04-24 00:50:48</td>\n",
|
9178 |
+
" </tr>\n",
|
9179 |
+
" </tbody>\n",
|
9180 |
+
"</table>\n",
|
9181 |
+
"</div>"
|
9182 |
+
],
|
9183 |
+
"text/plain": [
|
9184 |
+
" subreddit id \\\n",
|
9185 |
+
"0 theredpillrebooted 17c1wxt \n",
|
9186 |
+
"1 theredpillrebooted 16i06xc \n",
|
9187 |
+
"2 theredpillrebooted 16a4ekb \n",
|
9188 |
+
"3 theredpillrebooted 15f45sl \n",
|
9189 |
+
"4 theredpillrebooted 12wwyzc \n",
|
9190 |
+
"\n",
|
9191 |
+
" title \\\n",
|
9192 |
+
"0 My name is Benjamin Persits and I am so sick o... \n",
|
9193 |
+
"1 WHAT THE FUCK!?!?!?!? \n",
|
9194 |
+
"2 Why is she an asshole with me and how to handl... \n",
|
9195 |
+
"3 Popular US vlogger Gonzalo Lira aka Coach Red ... \n",
|
9196 |
+
"4 Mrs. Rooster by Stinky Buckets \n",
|
9197 |
+
"\n",
|
9198 |
+
" text \\\n",
|
9199 |
+
"0 Yes, I'm using my full name because I'm so sic... \n",
|
9200 |
+
"1 NaN \n",
|
9201 |
+
"2 So I got this girl who's kinda my crush but I ... \n",
|
9202 |
+
"3 &#x200B;\\n\\n[https://chng.it/gFyFvqS5K7](h... \n",
|
9203 |
+
"4 NaN \n",
|
9204 |
+
"\n",
|
9205 |
+
" url score \\\n",
|
9206 |
+
"0 NaN 0 \n",
|
9207 |
+
"1 https://v.redd.it/8d1eapsih3ob1 0 \n",
|
9208 |
+
"2 NaN 0 \n",
|
9209 |
+
"3 NaN 0 \n",
|
9210 |
+
"4 https://youtube.com/watch?v=jK5BQngWne4&fe... 1 \n",
|
9211 |
+
"\n",
|
9212 |
+
" author date \n",
|
9213 |
+
"0 benjypersits 2023-10-20 03:40:33 \n",
|
9214 |
+
"1 PatchesTheIdiot 2023-09-13 21:57:56 \n",
|
9215 |
+
"2 Worried-Horse-3408 2023-09-04 21:19:27 \n",
|
9216 |
+
"3 Beautiful_Diamond980 2023-08-01 06:21:36 \n",
|
9217 |
+
"4 LetsGoRedDevils 2023-04-24 00:50:48 "
|
9218 |
+
]
|
9219 |
+
},
|
9220 |
+
"execution_count": 11,
|
9221 |
+
"metadata": {},
|
9222 |
+
"output_type": "execute_result"
|
9223 |
+
}
|
9224 |
+
],
|
9225 |
+
"source": [
|
9226 |
+
"# fix the date column\n",
|
9227 |
+
"df[\"date\"] = pd.to_datetime(df[\"date\"], unit=\"s\")\n",
|
9228 |
+
"df.head()"
|
9229 |
+
]
|
9230 |
+
},
|
9231 |
+
{
|
9232 |
+
"cell_type": "code",
|
9233 |
+
"execution_count": 12,
|
9234 |
+
"metadata": {},
|
9235 |
+
"outputs": [],
|
9236 |
+
"source": [
|
9237 |
+
"df.to_csv(\"reddit_posts_fm.csv\", index=False)"
|
9238 |
+
]
|
9239 |
+
},
|
9240 |
+
{
|
9241 |
+
"cell_type": "code",
|
9242 |
+
"execution_count": 13,
|
9243 |
+
"metadata": {},
|
9244 |
+
"outputs": [
|
9245 |
+
{
|
9246 |
+
"data": {
|
9247 |
+
"text/html": [
|
9248 |
+
"<div>\n",
|
9249 |
+
"<style scoped>\n",
|
9250 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
9251 |
+
" vertical-align: middle;\n",
|
9252 |
+
" }\n",
|
9253 |
+
"\n",
|
9254 |
+
" .dataframe tbody tr th {\n",
|
9255 |
+
" vertical-align: top;\n",
|
9256 |
+
" }\n",
|
9257 |
+
"\n",
|
9258 |
+
" .dataframe thead th {\n",
|
9259 |
+
" text-align: right;\n",
|
9260 |
+
" }\n",
|
9261 |
+
"</style>\n",
|
9262 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
9263 |
+
" <thead>\n",
|
9264 |
+
" <tr style=\"text-align: right;\">\n",
|
9265 |
+
" <th></th>\n",
|
9266 |
+
" <th>subreddit</th>\n",
|
9267 |
+
" <th>id</th>\n",
|
9268 |
+
" <th>title</th>\n",
|
9269 |
+
" <th>text</th>\n",
|
9270 |
+
" <th>url</th>\n",
|
9271 |
+
" <th>score</th>\n",
|
9272 |
+
" <th>author</th>\n",
|
9273 |
+
" <th>date</th>\n",
|
9274 |
+
" </tr>\n",
|
9275 |
+
" </thead>\n",
|
9276 |
+
" <tbody>\n",
|
9277 |
+
" <tr>\n",
|
9278 |
+
" <th>0</th>\n",
|
9279 |
+
" <td>theredpillrebooted</td>\n",
|
9280 |
+
" <td>17c1wxt</td>\n",
|
9281 |
+
" <td>My name is Benjamin Persits and I am so sick o...</td>\n",
|
9282 |
+
" <td>Yes, I'm using my full name because I'm so sic...</td>\n",
|
9283 |
+
" <td>NaN</td>\n",
|
9284 |
+
" <td>0</td>\n",
|
9285 |
+
" <td>benjypersits</td>\n",
|
9286 |
+
" <td>2023-10-20 03:40:33</td>\n",
|
9287 |
+
" </tr>\n",
|
9288 |
+
" <tr>\n",
|
9289 |
+
" <th>1</th>\n",
|
9290 |
+
" <td>theredpillrebooted</td>\n",
|
9291 |
+
" <td>16i06xc</td>\n",
|
9292 |
+
" <td>WHAT THE FUCK!?!?!?!?</td>\n",
|
9293 |
+
" <td>NaN</td>\n",
|
9294 |
+
" <td>https://v.redd.it/8d1eapsih3ob1</td>\n",
|
9295 |
+
" <td>0</td>\n",
|
9296 |
+
" <td>PatchesTheIdiot</td>\n",
|
9297 |
+
" <td>2023-09-13 21:57:56</td>\n",
|
9298 |
+
" </tr>\n",
|
9299 |
+
" <tr>\n",
|
9300 |
+
" <th>2</th>\n",
|
9301 |
+
" <td>theredpillrebooted</td>\n",
|
9302 |
+
" <td>16a4ekb</td>\n",
|
9303 |
+
" <td>Why is she an asshole with me and how to handl...</td>\n",
|
9304 |
+
" <td>So I got this girl who's kinda my crush but I ...</td>\n",
|
9305 |
+
" <td>NaN</td>\n",
|
9306 |
+
" <td>0</td>\n",
|
9307 |
+
" <td>Worried-Horse-3408</td>\n",
|
9308 |
+
" <td>2023-09-04 21:19:27</td>\n",
|
9309 |
+
" </tr>\n",
|
9310 |
+
" <tr>\n",
|
9311 |
+
" <th>3</th>\n",
|
9312 |
+
" <td>theredpillrebooted</td>\n",
|
9313 |
+
" <td>15f45sl</td>\n",
|
9314 |
+
" <td>Popular US vlogger Gonzalo Lira aka Coach Red ...</td>\n",
|
9315 |
+
" <td>&amp;#x200B;\\n\\n[https://chng.it/gFyFvqS5K7](h...</td>\n",
|
9316 |
+
" <td>NaN</td>\n",
|
9317 |
+
" <td>0</td>\n",
|
9318 |
+
" <td>Beautiful_Diamond980</td>\n",
|
9319 |
+
" <td>2023-08-01 06:21:36</td>\n",
|
9320 |
+
" </tr>\n",
|
9321 |
+
" <tr>\n",
|
9322 |
+
" <th>4</th>\n",
|
9323 |
+
" <td>theredpillrebooted</td>\n",
|
9324 |
+
" <td>12wwyzc</td>\n",
|
9325 |
+
" <td>Mrs. Rooster by Stinky Buckets</td>\n",
|
9326 |
+
" <td>NaN</td>\n",
|
9327 |
+
" <td>https://youtube.com/watch?v=jK5BQngWne4&amp;fe...</td>\n",
|
9328 |
+
" <td>1</td>\n",
|
9329 |
+
" <td>LetsGoRedDevils</td>\n",
|
9330 |
+
" <td>2023-04-24 00:50:48</td>\n",
|
9331 |
+
" </tr>\n",
|
9332 |
+
" </tbody>\n",
|
9333 |
+
"</table>\n",
|
9334 |
+
"</div>"
|
9335 |
+
],
|
9336 |
+
"text/plain": [
|
9337 |
+
" subreddit id \\\n",
|
9338 |
+
"0 theredpillrebooted 17c1wxt \n",
|
9339 |
+
"1 theredpillrebooted 16i06xc \n",
|
9340 |
+
"2 theredpillrebooted 16a4ekb \n",
|
9341 |
+
"3 theredpillrebooted 15f45sl \n",
|
9342 |
+
"4 theredpillrebooted 12wwyzc \n",
|
9343 |
+
"\n",
|
9344 |
+
" title \\\n",
|
9345 |
+
"0 My name is Benjamin Persits and I am so sick o... \n",
|
9346 |
+
"1 WHAT THE FUCK!?!?!?!? \n",
|
9347 |
+
"2 Why is she an asshole with me and how to handl... \n",
|
9348 |
+
"3 Popular US vlogger Gonzalo Lira aka Coach Red ... \n",
|
9349 |
+
"4 Mrs. Rooster by Stinky Buckets \n",
|
9350 |
+
"\n",
|
9351 |
+
" text \\\n",
|
9352 |
+
"0 Yes, I'm using my full name because I'm so sic... \n",
|
9353 |
+
"1 NaN \n",
|
9354 |
+
"2 So I got this girl who's kinda my crush but I ... \n",
|
9355 |
+
"3 &#x200B;\\n\\n[https://chng.it/gFyFvqS5K7](h... \n",
|
9356 |
+
"4 NaN \n",
|
9357 |
+
"\n",
|
9358 |
+
" url score \\\n",
|
9359 |
+
"0 NaN 0 \n",
|
9360 |
+
"1 https://v.redd.it/8d1eapsih3ob1 0 \n",
|
9361 |
+
"2 NaN 0 \n",
|
9362 |
+
"3 NaN 0 \n",
|
9363 |
+
"4 https://youtube.com/watch?v=jK5BQngWne4&fe... 1 \n",
|
9364 |
+
"\n",
|
9365 |
+
" author date \n",
|
9366 |
+
"0 benjypersits 2023-10-20 03:40:33 \n",
|
9367 |
+
"1 PatchesTheIdiot 2023-09-13 21:57:56 \n",
|
9368 |
+
"2 Worried-Horse-3408 2023-09-04 21:19:27 \n",
|
9369 |
+
"3 Beautiful_Diamond980 2023-08-01 06:21:36 \n",
|
9370 |
+
"4 LetsGoRedDevils 2023-04-24 00:50:48 "
|
9371 |
+
]
|
9372 |
+
},
|
9373 |
+
"execution_count": 13,
|
9374 |
+
"metadata": {},
|
9375 |
+
"output_type": "execute_result"
|
9376 |
+
}
|
9377 |
+
],
|
9378 |
+
"source": [
|
9379 |
+
"df = pd.read_csv(\"reddit_posts_fm.csv\")\n",
|
9380 |
+
"df.head()"
|
9381 |
+
]
|
9382 |
+
},
|
9383 |
+
{
|
9384 |
+
"cell_type": "code",
|
9385 |
+
"execution_count": 14,
|
9386 |
+
"metadata": {},
|
9387 |
+
"outputs": [
|
9388 |
+
{
|
9389 |
+
"data": {
|
9390 |
+
"text/plain": [
|
9391 |
+
"subreddit object\n",
|
9392 |
+
"id object\n",
|
9393 |
+
"title object\n",
|
9394 |
+
"text object\n",
|
9395 |
+
"url object\n",
|
9396 |
+
"score int64\n",
|
9397 |
+
"author object\n",
|
9398 |
+
"date object\n",
|
9399 |
+
"dtype: object"
|
9400 |
+
]
|
9401 |
+
},
|
9402 |
+
"execution_count": 14,
|
9403 |
+
"metadata": {},
|
9404 |
+
"output_type": "execute_result"
|
9405 |
+
}
|
9406 |
+
],
|
9407 |
+
"source": [
|
9408 |
+
"df.dtypes"
|
9409 |
+
]
|
9410 |
+
},
|
9411 |
{
|
9412 |
"cell_type": "code",
|
9413 |
"execution_count": null,
|
|
|
9432 |
"name": "python",
|
9433 |
"nbconvert_exporter": "python",
|
9434 |
"pygments_lexer": "ipython3",
|
9435 |
+
"version": "3.11.7"
|
9436 |
}
|
9437 |
},
|
9438 |
"nbformat": 4,
|