Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 7e3b237

Browse files
committed
Fix code style issues with Black
1 parent a41833d commit 7e3b237

8 files changed

Lines changed: 137 additions & 78 deletions

File tree

projects/Live AQI/main.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#pip install geopy
2-
#pip install requests
3-
#Enter your API KEY from AIR VISUAL API
1+
# pip install geopy
2+
# pip install requests
3+
# Enter your API KEY from AIR VISUAL API
44

55
import tkinter as tk
66
import requests
@@ -30,7 +30,9 @@
3030
country_entry = tk.Entry(app)
3131
country_entry.pack()
3232

33-
get_aqi_button = tk.Button(app, text="Get AQI", bg="#3498db") # Set the background color of the button
33+
get_aqi_button = tk.Button(
34+
app, text="Get AQI", bg="#3498db"
35+
) # Set the background color of the button
3436
get_aqi_button.place(x=180, y=200)
3537

3638
# Add some space between the entry fields and the button
@@ -51,15 +53,16 @@
5153
AIRVISUAL_API_KEY = "YOUR API KEY"
5254
AIRVISUAL_API_URL = "https://api.airvisual.com/v2/city"
5355

56+
5457
def get_aqi():
5558
city = city_entry.get().strip() # Remove leading/trailing whitespaces
5659
state = state_entry.get().strip()
5760
country = country_entry.get()
58-
61+
5962
if city.lower() == "mumbai":
6063
city = "Mumbai"
6164
state = "Maharashtra"
62-
65+
6366
params = {
6467
"city": city,
6568
"state": state,

projects/Market Financial Sentiment Predictor/main.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
# Import Dataset
77
# This is a data (dummy) of Financial Market Top 25 News to Train and predict model for overall sentiment analysis.
8-
data = pd.read_csv("Financial Market News.csv", encoding = "ISO-8859-1")
8+
data = pd.read_csv("Financial Market News.csv", encoding="ISO-8859-1")
99

10-
#Analysis of dataset
10+
# Analysis of dataset
1111
data.head()
1212

1313
data.info()
@@ -16,16 +16,16 @@
1616

1717
data.columns
1818

19-
#Features selection
20-
' '.join(str(x) for x in data.iloc[1,2:27])
19+
# Features selection
20+
" ".join(str(x) for x in data.iloc[1, 2:27])
2121

2222
data.index
2323

2424
len(data.index)
2525

2626
news = []
27-
for row in range(0,len(data.index)):
28-
news.append(' '.join(str(x) for x in data.iloc[row,2:27]))
27+
for row in range(0, len(data.index)):
28+
news.append(" ".join(str(x) for x in data.iloc[row, 2:27]))
2929

3030
type(news)
3131

@@ -38,32 +38,33 @@
3838
# creating a bag of words
3939
from sklearn.feature_extraction.text import CountVectorizer
4040

41-
cv = CountVectorizer(lowercase = True, ngram_range=(1,1))
41+
cv = CountVectorizer(lowercase=True, ngram_range=(1, 1))
4242

4343
X = cv.fit_transform(X)
4444

4545
X.shape
4646

47-
y = data['Label']
47+
y = data["Label"]
4848

4949
y.shape
5050

51-
#Get train test split
51+
# Get train test split
5252
from sklearn.model_selection import train_test_split
5353

54-
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size= 0.3, stratify = y, random_state = 2529)
54+
X_train, X_test, y_train, y_test = train_test_split(
55+
X, y, test_size=0.3, stratify=y, random_state=2529
56+
)
5557

5658
from sklearn.ensemble import RandomForestClassifier
5759

5860
rf = RandomForestClassifier(n_estimators=200)
5961

60-
rf.fit(X_train,y_train)
62+
rf.fit(X_train, y_train)
6163

6264
y_pred = rf.predict(X_test)
6365

64-
from sklearn.metrics import classification_report,confusion_matrix,accuracy_score
66+
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score
6567

66-
confusion_matrix(y_test,y_pred)
67-
68-
print(classification_report(y_test,y_pred))
68+
confusion_matrix(y_test, y_pred)
6969

70+
print(classification_report(y_test, y_pred))

projects/Personal-Finance-tracker/main.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def __init__(self, name, amount, category):
44
self.amount = amount
55
self.category = category
66

7+
78
class FinanceManager:
89
def __init__(self):
910
self.expenses = []
@@ -18,12 +19,15 @@ def calculate_total_expenses(self):
1819

1920
def list_expenses(self):
2021
for expense in self.expenses:
21-
print(f"Name: {expense.name}, Amount: {expense.amount}, Category: {expense.category}")
22+
print(
23+
f"Name: {expense.name}, Amount: {expense.amount}, Category: {expense.category}"
24+
)
25+
2226

2327
# Sample usage
2428
if __name__ == "__main__":
2529
finance_manager = FinanceManager()
26-
30+
2731
while True:
2832
print("Personal Finance Manager")
2933
print("1. Add Expense")
@@ -37,13 +41,13 @@ def list_expenses(self):
3741
amount = float(input("Expense Amount: "))
3842
category = input("Expense Category: ")
3943
finance_manager.add_expense(name, amount, category)
40-
44+
4145
elif choice == "2":
4246
finance_manager.list_expenses()
43-
47+
4448
elif choice == "3":
4549
total_expenses = finance_manager.calculate_total_expenses()
4650
print(f"Total Expenses: {total_expenses}")
47-
51+
4852
elif choice == "4":
4953
break

projects/Skycast/get_geolocation/geolocation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from geopy.geocoders import Nominatim
22

3+
34
class GeolocationModel:
45
def __init__(self):
56
self.geolocator = Nominatim(user_agent="my-app")
7+
68
def get_location_by_name(self, location):
79
location_data = self.geolocator.geocode(location)
810

projects/Skycast/skycast.py

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from weather_forecast.forecast import WeatherForecast
55
import matplotlib.pyplot as plt
66

7+
78
class SkyCast:
89
def __init__(self):
910
self.geolocation_model = GeolocationModel()
@@ -15,16 +16,16 @@ def title(self):
1516
st.markdown(
1617
'<div style="border: 1px solid #ccc; padding: 20px; border-radius: 10px;">'
1718
'<h1 style="text-align: center; color: #0080FF;">SkyCast 🌤️</h1>'
18-
'</div>',
19-
unsafe_allow_html=True
19+
"</div>",
20+
unsafe_allow_html=True,
2021
)
2122

2223
def input(self):
2324
st.sidebar.title("Weather Options")
2425
self.weather_option = st.sidebar.radio(
2526
"Choose Weather Option",
2627
options=["Today's Weather", "Forecast Weather"],
27-
key="weather_option"
28+
key="weather_option",
2829
)
2930

3031
if self.weather_option == "Today's Weather":
@@ -33,7 +34,6 @@ def input(self):
3334
self.display_forecast_weather()
3435

3536
def display_today_weather(self):
36-
3737
latitude, longitude = None, None
3838
# Manually enter the city name
3939
city_name = st.sidebar.text_input("Enter City Name", key="city_name")
@@ -43,8 +43,10 @@ def display_today_weather(self):
4343
# If the submit button is not clicked, do not proceed further
4444
return
4545

46-
47-
st.markdown(f"<h2 style='text-align: center;'>Today's Weather</h2>", unsafe_allow_html=True)
46+
st.markdown(
47+
f"<h2 style='text-align: center;'>Today's Weather</h2>",
48+
unsafe_allow_html=True,
49+
)
4850

4951
if latitude is not None and longitude is not None:
5052
# Make API request
@@ -58,7 +60,7 @@ def display_today_weather(self):
5860
# Date and time
5961
st.markdown(
6062
f'<h3 style="text-align: center;">{weather_data["city_name"]}, {weather_data["country_code"]}: {datetime_value}</h3>',
61-
unsafe_allow_html=True
63+
unsafe_allow_html=True,
6264
)
6365

6466
# Additional weather information
@@ -71,7 +73,9 @@ def display_today_weather(self):
7173
st.markdown(f'Visibility: {weather_data["vis"]} km')
7274

7375
with col2:
74-
st.markdown(f'Weather Description: {weather_data["weather"]["description"]}')
76+
st.markdown(
77+
f'Weather Description: {weather_data["weather"]["description"]}'
78+
)
7579
st.markdown(f'Wind Direction: {weather_data["wind_cdir_full"]}')
7680
st.markdown(f'UV Index: {weather_data["uv"]}')
7781
st.markdown(f'Dew Point: {weather_data["dewpt"]}°C')
@@ -80,29 +84,41 @@ def display_today_weather(self):
8084
st.write("Location not found.")
8185

8286
def display_forecast_weather(self):
83-
8487
latitude, longitude = None, None
8588
# Manually enter the city name
8689
city_name = st.sidebar.text_input("Enter City Name", key="city_name")
87-
days = st.sidebar.number_input("How Many days do you want to Forecast", key="days", value=1, min_value=1, step=1, format="%d")
90+
days = st.sidebar.number_input(
91+
"How Many days do you want to Forecast",
92+
key="days",
93+
value=1,
94+
min_value=1,
95+
step=1,
96+
format="%d",
97+
)
8898

8999
if st.sidebar.button("Submit"):
90100
latitude, longitude = self.geolocation_model.get_location_by_name(city_name)
91101
else:
92102
# If the submit button is not clicked, do not proceed further
93103
return
94-
st.markdown(f"<h2 style='text-align: center;'>Forecast Weather</h2>", unsafe_allow_html=True)
104+
st.markdown(
105+
f"<h2 style='text-align: center;'>Forecast Weather</h2>",
106+
unsafe_allow_html=True,
107+
)
95108

96109
if latitude is not None and longitude is not None:
97110
# Create an instance of the WeatherForecast class
98-
weather = WeatherForecast(latitude, longitude, self.api_key,days)
111+
weather = WeatherForecast(latitude, longitude, self.api_key, days)
99112

100113
# Retrieve the weather forecast data
101114
forecast_df = weather.get_weather_forecast()
102115

103116
# Show forecast data
104117
for i in range(len(forecast_df)):
105-
st.markdown(f'<h3 style="text-align: center;">{forecast_df["date"][i]}</h3>', unsafe_allow_html=True)
118+
st.markdown(
119+
f'<h3 style="text-align: center;">{forecast_df["date"][i]}</h3>',
120+
unsafe_allow_html=True,
121+
)
106122

107123
col1, col2 = st.columns(2)
108124

@@ -113,7 +129,9 @@ def display_forecast_weather(self):
113129
st.markdown(f'Visibility: {forecast_df["visibility"][i]} km')
114130

115131
with col2:
116-
st.markdown(f'Weather Description: {forecast_df["weather_description"][i]}')
132+
st.markdown(
133+
f'Weather Description: {forecast_df["weather_description"][i]}'
134+
)
117135
st.markdown(f'Wind Direction: {forecast_df["wind_direction"][i]}')
118136
st.markdown(f'UV Index: {forecast_df["uv_index"][i]}')
119137
st.markdown(f'Dew Point: {forecast_df["dew_point"][i]}°C')
@@ -123,22 +141,38 @@ def display_forecast_weather(self):
123141
max_temp = forecast_df["max_temp"]
124142
date = forecast_df["date"]
125143

126-
st.set_option('deprecation.showPyplotGlobalUse', False)
144+
st.set_option("deprecation.showPyplotGlobalUse", False)
127145
plt.figure(figsize=(10, 6)) # Set the figure size
128146

129147
# Plot the temperature line
130-
plt.plot(date, temp, label='Temperature', marker='o', linestyle='-', color='blue')
148+
plt.plot(
149+
date, temp, label="Temperature", marker="o", linestyle="-", color="blue"
150+
)
131151

132152
# Plot the minimum temperature line
133-
plt.plot(date, min_temp, label='Min Temperature', marker='o', linestyle='-', color='green')
153+
plt.plot(
154+
date,
155+
min_temp,
156+
label="Min Temperature",
157+
marker="o",
158+
linestyle="-",
159+
color="green",
160+
)
134161

135162
# Plot the maximum temperature line
136-
plt.plot(date, max_temp, label='Max Temperature', marker='o', linestyle='-', color='red')
163+
plt.plot(
164+
date,
165+
max_temp,
166+
label="Max Temperature",
167+
marker="o",
168+
linestyle="-",
169+
color="red",
170+
)
137171

138172
# Set the labels and title
139-
plt.xlabel('Date')
140-
plt.ylabel('Temperature (°C)')
141-
plt.title('Temperature Forecast')
173+
plt.xlabel("Date")
174+
plt.ylabel("Temperature (°C)")
175+
plt.title("Temperature Forecast")
142176

143177
# Add a legend
144178
plt.legend()
@@ -154,7 +188,7 @@ def get_weather_data(self, latitude, longitude):
154188
"lat": latitude,
155189
"lon": longitude,
156190
"key": self.api_key,
157-
"include": "minutely"
191+
"include": "minutely",
158192
}
159193
try:
160194
response = requests.get(self.base_url, params=params)
@@ -174,4 +208,4 @@ def get_weather_data(self, latitude, longitude):
174208

175209
# Display the title and input fields
176210
weather_forecast.title()
177-
weather_forecast.input()
211+
weather_forecast.input()

0 commit comments

Comments
 (0)