merve HF staff commited on
Commit
d151dad
β€’
1 Parent(s): dd6db3e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas_profiling as pp
2
+ from huggingface_hub.hf_api import create_repo
3
+ from huggingface_hub.repository import Repository
4
+ import gradio as gr
5
+ import pandas as pd
6
+ import tempfile
7
+
8
+ token = gr.Textbox(label = "Your Hugging Face Token")
9
+ username = gr.Textbox(label = "Your Hugging Face User name")
10
+ dataset_name = gr.Textbox(label = "Dataset Name")
11
+ dataset = gr.File(label = "Dataset")
12
+ output_text = gr.Textbox(label = "Status")
13
+ title = "Dataset Profiler πŸͺ„βœ¨"
14
+ description = "Drag and drop any dataset you want to get a detailed profile on, and this Space will profile and push it to your Hub profile as a new Space. 🌟✨"
15
+
16
+ def profile_dataset(dataset, username, token, dataset_name):
17
+
18
+ df = pd.read_csv(dataset.name)
19
+ profile = pp.ProfileReport(df, title=f"{dataset_name} Report")
20
+
21
+ url = create_repo(f"{username}/{dataset_name}", repo_type = "space", token = token, space_sdk = "static")
22
+ repo = Repository(
23
+ local_dir = f"{username}/{dataset_name}",
24
+ clone_from=url,
25
+ use_auth_token=token,
26
+ repo_type = "space"
27
+ )
28
+ repo.git_pull(rebase=True)
29
+ profile.to_file(f"{username}/{dataset_name}/index.html")
30
+ repo.git_add()
31
+ repo.git_commit(commit_message = "Dataset report")
32
+ repo.git_push()
33
+ return f"Your dataset report will be ready at {url}"
34
+
35
+ gr.Interface(profile_dataset, inputs = [dataset, username, token, dataset_name], outputs=[output_text], enable_queue = True).launch(debug=True)