Update README.md
Browse files
README.md
CHANGED
|
@@ -39,10 +39,10 @@ The transformation was performed using the following DuckDB query:
|
|
| 39 |
```python
|
| 40 |
import duckdb
|
| 41 |
|
| 42 |
-
Connect to a new DuckDB database
|
| 43 |
new_db = duckdb.connect('merged_notebooks.db')
|
| 44 |
|
| 45 |
-
Query to concatenate markdown, code, and output
|
| 46 |
query = """
|
| 47 |
SELECT path,
|
| 48 |
STRING_AGG(CONCAT('###Markdown\n', markdown, '\n###Code\n', code, '\n###Output\n', output), '\n') AS concatenated_notebook
|
|
@@ -50,5 +50,19 @@ FROM read_parquet('jupyter-code-text-pairs/data/*.parquet')
|
|
| 50 |
GROUP BY path
|
| 51 |
"""
|
| 52 |
|
| 53 |
-
Execute the query and create a new table
|
| 54 |
-
new_db.execute(f"CREATE TABLE concatenated_notebooks AS {query}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
```python
|
| 40 |
import duckdb
|
| 41 |
|
| 42 |
+
#Connect to a new DuckDB database
|
| 43 |
new_db = duckdb.connect('merged_notebooks.db')
|
| 44 |
|
| 45 |
+
#Query to concatenate markdown, code, and output
|
| 46 |
query = """
|
| 47 |
SELECT path,
|
| 48 |
STRING_AGG(CONCAT('###Markdown\n', markdown, '\n###Code\n', code, '\n###Output\n', output), '\n') AS concatenated_notebook
|
|
|
|
| 50 |
GROUP BY path
|
| 51 |
"""
|
| 52 |
|
| 53 |
+
#Execute the query and create a new table
|
| 54 |
+
new_db.execute(f"CREATE TABLE concatenated_notebooks AS {query}")
|
| 55 |
+
```
|
| 56 |
+
## Usage
|
| 57 |
+
|
| 58 |
+
To replicate the transformation or explore the original dataset, you can download it using the following command:
|
| 59 |
+
|
| 60 |
+
```bash
|
| 61 |
+
git clone https://huggingface.co/datasets/bigcode/jupyter-code-text-pairs
|
| 62 |
+
|
| 63 |
+
```
|
| 64 |
+
Once downloaded, you can use the provided DuckDB query to process the data as needed.
|
| 65 |
+
|
| 66 |
+
## Conclusion
|
| 67 |
+
|
| 68 |
+
This dataset provides a more integrated view of Jupyter notebooks by merging markdown, code, and output into a single format. The use of DuckDB demonstrates its capability to handle large datasets efficiently, making it an excellent tool for data transformation tasks.
|