AliUsama98 commited on
Commit
da528de
1 Parent(s): 1872364

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -72
app.py CHANGED
@@ -1,82 +1,32 @@
1
- import gradio as gr
2
-
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
-
6
-
7
-
8
-
9
-
10
- # Import pandas
11
  import pandas as pd
12
-
13
- # Use pandas to read in recent_grads_url
14
- recent_grads = pd.read_csv("/content/recent_grads.csv")
15
-
16
- # Print the shape
17
- print(recent_grads.shape)
18
-
19
- from google.colab import drive
20
- drive.mount('/content/drive')
21
-
22
- # Print .dtypes
23
- print(recent_grads.dtypes)
24
-
25
- # Output summary statistics
26
- print(recent_grads.describe())
27
-
28
- # Exclude data of type object
29
- print(recent_grads.describe(exclude=["object"]))
30
-
31
- # Names of the columns we're searching for missing values
32
- columns = ['median', 'p25th', 'p75th']
33
-
34
- # Take a look at the dtypes
35
- print(recent_grads[columns].dtypes)
36
-
37
- # Find how missing values are represented
38
- print(recent_grads["median"].unique())
39
-
40
- # Replace missing values with NaN
41
- for column in columns:
42
- recent_grads.loc[recent_grads[column] == 'UN', column] = np.nan
43
-
44
  import numpy as np
45
- import pandas as pd
46
 
47
- # Assuming 'recent_grads' is your DataFrame and 'columns' is a list of columns needing correction
 
 
 
 
 
48
 
49
- # Replace missing values with NaN
50
- for column in columns:
51
- recent_grads.loc[recent_grads[column] == 'UN', column] = np.nan
52
 
53
- # Select sharewomen column
54
- sw_col = recent_grads['sharewomen']
 
55
 
56
- # Output first five rows
57
- print(sw_col.head())
58
 
59
- # Import numpy
60
- import numpy as np
61
-
62
- # Use max to output maximum values
63
- max_sw = recent_grads['sharewomen'].max()
64
-
65
- # Print column max
66
- print(max_sw)
67
-
68
- # Output the row containing the maximum percentage of women
69
- #print(sw_col)
70
- print(recent_grads[(recent_grads['sharewomen']==max_sw)])
71
-
72
- # Convert to numpy array
73
- import numpy as np
74
- recent_grads_np=np.array(recent_grads[['unemployed', 'low_wage_jobs']])
75
 
 
 
76
 
77
- # Print the type of recent_grads_np
78
- print(type(recent_grads_np))
 
79
 
80
- print(np.corrcoef(recent_grads_np[:,0], recent_grads_np[:,1]))
81
- iface = gr.Interface(fn=greet, inputs="text", outputs=recent_grads[(recent_grads['sharewomen']==max_sw])
82
- iface.launch()
 
1
+ import streamlit as st
 
 
 
 
 
 
 
 
 
2
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  import numpy as np
 
4
 
5
+ # Function to load data and replace missing values
6
+ @st.cache
7
+ def load_data():
8
+ # Load your data here, assuming 'recent_grads' is your DataFrame
9
+ # Replace 'your_data.csv' with your actual data file
10
+ recent_grads = pd.read_csv('your_data.csv')
11
 
12
+ # List of columns needing correction
13
+ columns_to_correct = ['column1', 'column2', 'column3'] # Replace these with your columns
 
14
 
15
+ # Replace 'UN' with NaN in specified columns
16
+ for column in columns_to_correct:
17
+ recent_grads.loc[recent_grads[column] == 'UN', column] = np.nan
18
 
19
+ return recent_grads
 
20
 
21
+ def main():
22
+ st.title('Data Handling with Streamlit')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ # Load data
25
+ data = load_data()
26
 
27
+ # Show the loaded data in Streamlit
28
+ st.write("Original Data:")
29
+ st.write(data)
30
 
31
+ if __name__ == "__main__":
32
+ main()