Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from ydata_profiling import ProfileReport
|
3 |
+
|
4 |
+
def generate_profile(file):
|
5 |
+
# Load the uploaded file into a pandas dataframe
|
6 |
+
df = pd.read_csv(file.name)
|
7 |
+
|
8 |
+
# Generate the profile report
|
9 |
+
profile = ProfileReport(df, title="Pandas Profiling Report")
|
10 |
+
|
11 |
+
# Convert the profile report to a JSON format
|
12 |
+
profile_json = profile.to_json()
|
13 |
+
|
14 |
+
# Load the JSON into a pandas dataframe
|
15 |
+
profile_data = json.loads(profile_json)
|
16 |
+
df_profile = pd.json_normalize(profile_data)
|
17 |
+
|
18 |
+
return df_profile
|
19 |
+
|
20 |
+
# Create a Gradio interface
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=generate_profile,
|
23 |
+
inputs=gr.inputs.File(label="Upload CSV File"),
|
24 |
+
outputs=gr.outputs.Dataframe(label="Profile Data")
|
25 |
+
)
|
26 |
+
|
27 |
+
# Launch the app
|
28 |
+
iface.launch()
|