Spaces:
Runtime error
Runtime error
AliUsama98
commited on
Commit
•
da528de
1
Parent(s):
1872364
Update app.py
Browse files
app.py
CHANGED
@@ -1,82 +1,32 @@
|
|
1 |
-
import
|
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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
#
|
50 |
-
|
51 |
-
recent_grads.loc[recent_grads[column] == 'UN', column] = np.nan
|
52 |
|
53 |
-
#
|
54 |
-
|
|
|
55 |
|
56 |
-
|
57 |
-
print(sw_col.head())
|
58 |
|
59 |
-
|
60 |
-
|
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 |
-
#
|
78 |
-
|
|
|
79 |
|
80 |
-
|
81 |
-
|
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()
|
|