Use native timestamps, booleans, integers, and nulls for subreddit metadata
Browse filesFiles changed (4)
- README.md+15-23
- conversion-manifest.json+31-10
- convert.py+92-12
- data/data.parquet+2-2
26 unmodified lines272829303132333435363738394041424344451 unmodified line474849505152535455564 unmodified lines61626364656667686970717273747576777879808182838485868788899016 unmodified lines1071081091101111121131142 unmodified lines11711811912012112212312426 unmodified lines- name: display_namedtype: string- name: created_utcdtype: string- name: over18dtype: string- name: urldtype: string- name: subscribersdtype: string- name: public_descriptiondtype: string- name: subredditdtype: string- name: retrieved_ondtype: string- name: rules_markdowndtype: string- name: descp1 unmodified lineconfig_name: defaultsplits:- name: datanum_bytes: 409798485num_examples: 395018download_size: 183178103dataset_size: 409798485---# Subreddits Directory4 unmodified lines**This dataset contains historical metadata.** The publication date of this repository is not the collection date. Names, descriptions, member counts, rules, availability, and other values reflect previously collected records. Where available, `retrieved_on` provides a record's retrieval timestamp. This is not a verified directory of every currently existing subreddit.## Data and preservationThe single file `data/data.parquet` uses Zstandard compression and is 183,178,103 bytes (approximately 183 MB). The `data` split contains the entire table. It is a general-purpose directory of subreddit metadata, with no predefined task or evaluation partition.All original column names, parsed cell values, row order, and column order are preserved. No rows were filtered, deduplicated, added, or reordered. No descriptions were rewritten, combined, trimmed, or filled in. Existing rules and other auxiliary columns are retained.Every column is stored as a **string**, including counts, booleans, and timestamps. This deliberately avoids changing numeric spellings, boolean spellings, or timestamp representations during CSV type inference. Empty CSV cells remain empty strings, not nulls. CSV quoting and delimiters are serialization details and are replaced by Parquet encoding.The conversion was verified by comparing **every cell of every row** with the original records. `conversion-manifest.json` records the validation result, file SHA-256 checksums, schema, and empty-string counts. The Parquet file contains the complete published table and can be used independently.## Columns| Column | Meaning | Empty cells ||---|---|---:|| `title` | Subreddit title. | 18 || `description` | Longer subreddit description/sidebar text. | 161,178 || `display_name` | Subreddit display name. | 1 || `created_utc` | Community creation-time value in its original representation. | 0 || `over18` | Adult-content/NSFW flag, retained as text. | 0 || `url` | Community URL or relative Reddit path. | 0 || `subscribers` | Subscriber/member count at collection time, retained as text. | 0 || `public_description` | Short public subreddit description. | 54,126 || `subreddit` | Subreddit name. | 0 || `retrieved_on` | Retrieval-time value, when provided; retained verbatim. | 259,611 || `rules_markdown` | Community rules in Markdown, when provided. | 259,611 || `descp` | Auxiliary description field. Its original construction is undocumented; it is preserved without reinterpretation. | 0 |16 unmodified linesrow = next(iter(dataset))```Consumers can explicitly parse numeric or date columns for their own analysis. No such coercion is applied to the published data.## Download the Parquet fileDownload directly from this repository with the Hugging Face CLI:2 unmodified lineshf download semvec/subreddits-directory data/data.parquet --repo-type dataset --local-dir subreddits-directory```The repository also includes `convert.py`, the CSV-to-Parquet conversion and validation script used to prepare this edition. It is not needed to load or download the dataset.## Usage terms and limitationsThe full original collection methodology is not documented. Community flags and metadata have not been independently validated, and completeness is not guaranteed.26 unmodified lines272829303132333435363738394041424344451 unmodified line474849505152535455564 unmodified lines616263646566676869707172737475767778798081828384858616 unmodified lines1031041051061071082 unmodified lines11111211311411511626 unmodified lines- name: display_namedtype: string- name: created_utcdtype: timestamp[us, tz=UTC]- name: over18dtype: bool- name: urldtype: string- name: subscribersdtype: int64- name: public_descriptiondtype: string- name: subredditdtype: string- name: retrieved_ondtype: timestamp[us, tz=UTC]- name: rules_markdowndtype: string- name: descp1 unmodified lineconfig_name: defaultsplits:- name: datanum_bytes: 400524343num_examples: 395018download_size: 184146598dataset_size: 400524343---# Subreddits Directory4 unmodified lines**This dataset contains historical metadata.** The publication date of this repository is not the collection date. Names, descriptions, member counts, rules, availability, and other values reflect previously collected records. Where available, `retrieved_on` provides a record's retrieval timestamp. This is not a verified directory of every currently existing subreddit.## Dataset contentsEach record describes a Reddit community through its name, title, descriptions, member count, creation and retrieval dates, adult-content flag, and available rules. The `data` split contains the complete directory.All original records and columns are retained in their original order. Descriptions and rules have not been rewritten, and no metadata has been refreshed. Missing values and any duplicate records remain part of the dataset.## Columns| Column | Meaning | Missing values ||---|---|---:|| `title` | Subreddit title. | 18 || `description` | Longer subreddit description/sidebar text. | 161,178 || `display_name` | Subreddit display name. | 1 || `created_utc` | When the community was created (UTC). | 0 || `over18` | Whether the community is marked as adult content/NSFW. | 0 || `url` | Community URL or relative Reddit path. | 0 || `subscribers` | Subscriber/member count at collection time. | 0 || `public_description` | Short public subreddit description. | 54,126 || `subreddit` | Subreddit name. | 0 || `retrieved_on` | When the metadata was retrieved (UTC), where available. | 259,611 || `rules_markdown` | Community rules in Markdown, when provided. | 259,611 || `descp` | Auxiliary description field. Its original construction is undocumented; it is preserved without reinterpretation. | 0 |16 unmodified linesrow = next(iter(dataset))```## Download the Parquet fileDownload directly from this repository with the Hugging Face CLI:2 unmodified lineshf download semvec/subreddits-directory data/data.parquet --repo-type dataset --local-dir subreddits-directory```## Usage terms and limitationsThe full original collection methodology is not documented. Community flags and metadata have not been independently validated, and completeness is not guaranteed.
4 unmodified lines5678910111214 unmodified lines27282930313233343536373839404142438 unmodified lines5253545556575859602 unmodified lines636465666768694 unmodified lines"source_sha256": "a449ece09a2115e8eba670a0d00cc0cca734b4b3d85d289dcd5f6f2becd833b1","source_license_identifier": "reddit-api","parquet_file": "data/data.parquet","parquet_bytes": 183178103,"parquet_sha256": "20cd09b4fed1c12bd316574c43a0ebaae0beb27b75c74d58c1057eb2104a0746","row_count": 395018,"column_count": 12,"columns": [14 unmodified lines"title": "string","description": "string","display_name": "string","created_utc": "string","over18": "string","url": "string","subscribers": "string","public_description": "string","subreddit": "string","retrieved_on": "string","rules_markdown": "string","descp": "string"},"empty_string_counts": {"title": 18,"description": 161178,"display_name": 1,8 unmodified lines"descp": 0},"validation": {"method": "Full row-by-row and cell-by-cell comparison with parsed source CSV","verified_rows": 395018,"all_values_identical": true,"row_order_preserved": true,"column_order_preserved": true},2 unmodified lines"compression": "zstd","csv_encoding": "utf-8","type_inference": false,"empty_fields": "Preserved as empty strings; no null inference","metadata_refreshed": false}}4 unmodified lines5678910111214 unmodified lines272829303132333435363738394041424344454647484950515253545556578 unmodified lines66676869707172737475762 unmodified lines7980818283848586878889904 unmodified lines"source_sha256": "a449ece09a2115e8eba670a0d00cc0cca734b4b3d85d289dcd5f6f2becd833b1","source_license_identifier": "reddit-api","parquet_file": "data/data.parquet","parquet_bytes": 184146598,"parquet_sha256": "c8a520b2d2785cf79c9baa23ba98f904e5bee2e146acb6ff9b20aa345ddddb68","row_count": 395018,"column_count": 12,"columns": [14 unmodified lines"title": "string","description": "string","display_name": "string","created_utc": "timestamp[us, tz=UTC]","over18": "bool","url": "string","subscribers": "int64","public_description": "string","subreddit": "string","retrieved_on": "timestamp[us, tz=UTC]","rules_markdown": "string","descp": "string"},"source_empty_string_counts": {"title": 18,"description": 161178,"display_name": 1,"created_utc": 0,"over18": 0,"url": 0,"subscribers": 0,"public_description": 54126,"subreddit": 0,"retrieved_on": 259611,"rules_markdown": 259611,"descp": 0},"null_counts": {"title": 18,"description": 161178,"display_name": 1,8 unmodified lines"descp": 0},"validation": {"method": "Full cell-by-cell comparison: exact nonempty text, inverse semantic comparisons for typed values, empty cells mapped to null","verified_rows": 395018,"all_semantic_values_match": true,"nonempty_text_unchanged": true,"null_counts_match_source_empty_cells": true,"row_order_preserved": true,"column_order_preserved": true},2 unmodified lines"compression": "zstd","csv_encoding": "utf-8","type_inference": false,"empty_fields": "Only exact empty strings become null; literal null-like text is preserved","created_utc": "ISO 8601 UTC to timestamp[us, tz=UTC]","retrieved_on": "Unix seconds to timestamp[us, tz=UTC] using exact decimal arithmetic","over18": "True/False text to boolean","subscribers": "Nonnegative integer text to int64","write_page_index": true,"metadata_refreshed": false}}
12345671 unmodified line91011121314151617181910 unmodified lines303132333435363738394041424344454647484950515253545556575859607 unmodified lines6869707172737475767778792 unmodified lines82838485868788"""Losslessly convert the source CSV's parsed cells to Parquet.Usage: python convert.py path/to/subreddits_with_details.csv output_directoryRequires pyarrow. No Reddit requests, cleanup, filtering, or type inference."""import csv1 unmodified lineimport itertoolsimport jsonimport sysfrom pathlib import Pathimport pyarrow as paimport pyarrow.parquet as pqdef sha256(path):with path.open("rb") as stream:10 unmodified linesreader = csv.reader(stream, strict=True)columns = next(reader)assert len(set(columns)) == len(columns), "Duplicate source column names"schema = pa.schema([(name, pa.string()) for name in columns])empty_counts = dict.fromkeys(columns, 0)with pq.ParquetWriter(target, schema, compression="zstd") as writer:while rows := list(itertools.islice(reader, 5000)):assert all(len(row) == len(columns) for row in rows), "Ragged CSV row"arrays = []for index, name in enumerate(columns):values = [row[index] for row in rows]empty_counts[name] += values.count("")arrays.append(pa.array(values, type=pa.string()))writer.write_table(pa.Table.from_arrays(arrays, schema=schema))row_count += len(rows)# Independently read the original CSV again and compare every output cell.verified_rows = 0with source.open(encoding="utf-8", newline="") as stream:reader = csv.reader(stream, strict=True)assert next(reader) == columnsfor batch in pq.ParquetFile(target).iter_batches(batch_size=5000):assert batch.schema.names == columnsfor row in zip(*(column.to_pylist() for column in batch.columns)):assert list(row) == next(reader), f"Mismatch at row {verified_rows}"verified_rows += 1assert next(reader, None) is None, "Source has additional rows"assert verified_rows == row_countmanifest = {"source": "https://www.kaggle.com/datasets/hashiromer/subreddits-directory",7 unmodified lines"row_count": row_count,"column_count": len(columns),"columns": columns,"column_types": dict.fromkeys(columns, "string"),"empty_string_counts": empty_counts,"validation": {"method": "Full row-by-row and cell-by-cell comparison with parsed source CSV","verified_rows": verified_rows,"all_values_identical": True,"row_order_preserved": True,"column_order_preserved": True,},2 unmodified lines"compression": "zstd","csv_encoding": "utf-8","type_inference": False,"empty_fields": "Preserved as empty strings; no null inference","metadata_refreshed": False,},}12345671 unmodified line910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777810 unmodified lines89909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311327 unmodified lines1401411421431441451461471481491501511521531542 unmodified lines157158159160161162163164165166167168"""Convert subreddit metadata to Parquet with explicit semantic types.Usage: python convert.py path/to/subreddits_with_details.csv output_directoryRequires pyarrow. No Reddit requests, filtering, or metadata refresh."""import csv1 unmodified lineimport itertoolsimport jsonimport sysfrom datetime import datetime, timedelta, timezonefrom decimal import Decimalfrom pathlib import Pathimport pyarrow as paimport pyarrow.parquet as pqEPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc)TIMESTAMP = pa.timestamp("us", tz="UTC")TYPES = {"created_utc": TIMESTAMP,"retrieved_on": TIMESTAMP,"over18": pa.bool_(),"subscribers": pa.int64(),}def parse_cell(name, value):if value == "":return Noneif name == "created_utc":parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))if parsed.tzinfo is None:raise ValueError(f"Creation timestamp lacks timezone: {value!r}")return parsed.astimezone(timezone.utc)if name == "retrieved_on":micros = Decimal(value) * 1_000_000if not micros.is_finite() or micros != micros.to_integral_value():raise ValueError(f"Invalid or sub-microsecond retrieval timestamp: {value!r}")return EPOCH + timedelta(microseconds=int(micros))if name == "over18":if value not in ("True", "False"):raise ValueError(f"Unexpected boolean: {value!r}")return value == "True"if name == "subscribers":if not value.isascii() or not value.isdecimal():raise ValueError(f"Invalid subscriber count: {value!r}")return int(value)return valuedef verify_cell(name, original, converted):"""Check output against source using inverse semantic comparisons."""if original == "":return converted is Noneif converted is None:return Falseif name == "created_utc":# The source uses either minute or second precision, always UTC.return original in (converted.strftime("%Y-%m-%dT%H:%M:%SZ"),converted.strftime("%Y-%m-%dT%H:%MZ")if converted.second == converted.microsecond == 0 else "",) and converted.utcoffset() == timedelta(0)if name == "retrieved_on":delta = converted - EPOCHmicros = (delta.days * 86400 + delta.seconds) * 1_000_000 + delta.microsecondsreturn Decimal(micros) / 1_000_000 == Decimal(original)if name == "over18":return type(converted) is bool and str(converted) == originalif name == "subscribers":return type(converted) is int and Decimal(converted) == Decimal(original)return converted == originaldef sha256(path):with path.open("rb") as stream:10 unmodified linesreader = csv.reader(stream, strict=True)columns = next(reader)assert len(set(columns)) == len(columns), "Duplicate source column names"schema = pa.schema([(name, TYPES.get(name, pa.string())) for name in columns])empty_counts = dict.fromkeys(columns, 0)with pq.ParquetWriter(target, schema, compression="zstd", write_page_index=True) as writer:while rows := list(itertools.islice(reader, 5000)):assert all(len(row) == len(columns) for row in rows), "Ragged CSV row"arrays = []for index, name in enumerate(columns):values = [row[index] for row in rows]empty_counts[name] += values.count("")arrays.append(pa.array([parse_cell(name, value) for value in values],type=schema.field(name).type,))writer.write_table(pa.Table.from_arrays(arrays, schema=schema))row_count += len(rows)# Independently read the original CSV again and compare every output cell.verified_rows = 0null_counts = dict.fromkeys(columns, 0)parquet = pq.ParquetFile(target)assert parquet.schema_arrow.equals(schema), "Parquet schema mismatch"with source.open(encoding="utf-8", newline="") as stream:reader = csv.reader(stream, strict=True)assert next(reader) == columnsfor batch in parquet.iter_batches(batch_size=5000):assert batch.schema.names == columnsfor name, array in zip(columns, batch.columns):null_counts[name] += array.null_countfor row in zip(*(column.to_pylist() for column in batch.columns)):original = next(reader)assert all(verify_cell(name, old, new)for name, old, new in zip(columns, original, row)), f"Mismatch at row {verified_rows}"verified_rows += 1assert next(reader, None) is None, "Source has additional rows"assert verified_rows == row_countassert null_counts == empty_counts, "Null counts differ from source empty cells"manifest = {"source": "https://www.kaggle.com/datasets/hashiromer/subreddits-directory",7 unmodified lines"row_count": row_count,"column_count": len(columns),"columns": columns,"column_types": {field.name: str(field.type) for field in schema},"source_empty_string_counts": empty_counts,"null_counts": null_counts,"validation": {"method": "Full cell-by-cell comparison: exact nonempty text, inverse semantic comparisons for typed values, empty cells mapped to null","verified_rows": verified_rows,"all_semantic_values_match": True,"nonempty_text_unchanged": True,"null_counts_match_source_empty_cells": True,"row_order_preserved": True,"column_order_preserved": True,},2 unmodified lines"compression": "zstd","csv_encoding": "utf-8","type_inference": False,"empty_fields": "Only exact empty strings become null; literal null-like text is preserved","created_utc": "ISO 8601 UTC to timestamp[us, tz=UTC]","retrieved_on": "Unix seconds to timestamp[us, tz=UTC] using exact decimal arithmetic","over18": "True/False text to boolean","subscribers": "Nonnegative integer text to int64","write_page_index": True,"metadata_refreshed": False,},}
123version https://git-lfs.github.com/spec/v1oid sha256:20cd09b4fed1c12bd316574c43a0ebaae0beb27b75c74d58c1057eb2104a0746size 183178103123version https://git-lfs.github.com/spec/v1oid sha256:c8a520b2d2785cf79c9baa23ba98f904e5bee2e146acb6ff9b20aa345ddddb68size 184146598
README.md+15-23
conversion-manifest.json+31-10
convert.py+92-12
data/data.parquet+2-2