varshitha22 commited on
Commit
6ecb34c
·
verified ·
1 Parent(s): a2be647

Update pages/EDA.py

Browse files
Files changed (1) hide show
  1. pages/EDA.py +128 -1
pages/EDA.py CHANGED
@@ -195,6 +195,7 @@ st.markdown("""
195
  <div class='insights-box'>
196
  1. Banana is the most frequent crop, indicating it requires high soil nutrients.<br>
197
  2. Rice, Papaya, and Jute also need good nutrients but less than Banana.
 
198
  </div>
199
  """, unsafe_allow_html=True)
200
 
@@ -225,6 +226,132 @@ st.markdown("""
225
  </style>
226
  <div class='insights-box'>
227
  1. Orange, Mango, and Coconut are the most frequent crops found in nutrient-poor soil.<br>
228
- 2. These crops are well-adapted to low-fertility conditions and can grow even when nutrient levels are below average..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  </div>
230
  """, unsafe_allow_html=True)
 
195
  <div class='insights-box'>
196
  1. Banana is the most frequent crop, indicating it requires high soil nutrients.<br>
197
  2. Rice, Papaya, and Jute also need good nutrients but less than Banana.
198
+ 3. Chickpea appears the least, suggesting it can grow in soils with relatively lower nutrients.
199
  </div>
200
  """, unsafe_allow_html=True)
201
 
 
226
  </style>
227
  <div class='insights-box'>
228
  1. Orange, Mango, and Coconut are the most frequent crops found in nutrient-poor soil.<br>
229
+ 2. These crops are well-adapted to low-fertility conditions and can grow even when nutrient levels are below average.
230
+ 3. Unlike Banana and Rice, which need nutrient-rich soil to grow well, crops like Orange, Mango, and Coconut can survive with fewer nutrients. These fruit trees are naturally more resistant to dry conditions and can grow even in sandy or less fertile soils.
231
+ </div>
232
+ """, unsafe_allow_html=True)
233
+ st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'>How This Helps Farmers:</h2>", unsafe_allow_html=True)
234
+ st.markdown("<h2 style='color: #D35400; font-size: 20px;'>Choosing the Right Crops for Low-Fertility Soil:</h2>", unsafe_allow_html=True)
235
+ st.markdown("""
236
+ <style>
237
+ .insights-box {
238
+ font-size: 18px;
239
+ color: #333;
240
+ background-color: #f9f9f9;
241
+ padding: 8px;
242
+ border-radius: 8px;
243
+ border-left: 4px solid #2E86C1;
244
+ }
245
+ </style>
246
+ <div class='insights-box'>
247
+ 1. If the soil is not very rich in nutrients, farmers should avoid growing crops like Banana or Rice, which need a lot of nutrients to grow well.
248
+ 2. Instead, they can plant fruit trees like Orange, Mango, and Coconut, which can survive and produce good yields even in poor soil.
249
+ </div>
250
+ """, unsafe_allow_html=True)
251
+ st.markdown("<h2 style='color: #D35400; font-size: 20px;'>Improving Soil Naturally with Legumes:</h2>", unsafe_allow_html=True)
252
+ st.markdown("""
253
+ <style>
254
+ .insights-box {
255
+ font-size: 18px;
256
+ color: #333;
257
+ background-color: #f9f9f9;
258
+ padding: 8px;
259
+ border-radius: 8px;
260
+ border-left: 4px solid #2E86C1;
261
+ }
262
+ </style>
263
+ <div class='insights-box'>
264
+ 1. Leguminous crops like MungBean and MothBeans help the soil by adding nitrogen naturally.
265
+ 2. If farmers grow these crops in rotation with other crops, the soil will become more fertile over time, reducing the need for chemical fertilizers.
266
+ </div>
267
+ """, unsafe_allow_html=True)
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+ st.markdown("<h2 style='text-align: left; color: #D35400;font-size: 23px;'>Crops that require above-average sclimate factors</h2>", unsafe_allow_html=True)
277
+
278
+ # Calculate average of climate factors
279
+ avg_nitrogen = df['Temperature'].mean()
280
+ avg_phosphorus = df['Humidity'].mean()
281
+ avg_potassium = df['pH_Value'].mean()
282
+ avg_rainfall = df['Rainfall'].mean()
283
+
284
+ # Function to plot bar charts
285
+ def plot_climate_crops(data, title):
286
+ clim_crop_counts = data.value_counts()
287
+ fig, ax = plt.subplots(figsize=(6, 3)) # Adjusted plot size for better display
288
+ clim_crop_counts.plot(kind='bar', color='skyblue', ax=ax)
289
+ ax.set_xlabel('Crops', fontsize=8)
290
+ ax.set_ylabel('Count', fontsize=8)
291
+ ax.set_title(title, fontsize=8)
292
+ ax.tick_params(axis='x', labelsize=8) # Adjust x-axis label size
293
+ ax.tick_params(axis='y', labelsize=8) # Adjust y-axis label size
294
+ st.pyplot(fig)
295
+
296
+ # Plot: Crops in climate factors
297
+ more_avg_of_Climate_Factors = df[
298
+ (df['Temperature'] >= avg_Temperature) &
299
+ (df['Humidity'] >= avg_Humidity) &
300
+ (df['pH_Value'] >= avg_pH_Value)&
301
+ (df['Rainfall'] >= avg_Rainfall)
302
+ ]['Crop']
303
+
304
+ plot_climate_crops(more_avg_of_Climate_Factors, "Crops Growing in climate factors")
305
+
306
+ # Insights
307
+ st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'>Insights:</h2>", unsafe_allow_html=True)
308
+ st.markdown("""
309
+ <style>
310
+ .insights-box {
311
+ font-size: 19px;
312
+ color: #333;
313
+ background-color: #f9f9f9;
314
+ padding: 8px;
315
+ border-radius: 8px;
316
+ border-left: 4px solid #2E86C1;
317
+ }
318
+ </style>
319
+ <div class='insights-box'>
320
+ 1. Papaya and orange grow best in warm, humid, and rainy climates.
321
+ 2. Jute and rice do well in high rainfall areas.
322
+ 3. Maize and cotton grow the least, meaning they might prefer drier climates.
323
+ </div>
324
+ """, unsafe_allow_html=True)
325
+
326
+ # Below-Average climate factors Requirement Crops
327
+ st.markdown("<h2 style='text-align: left; color: #D35400;font-size: 23px;'>Crops that require below-average climate factors</h2>", unsafe_allow_html=True)
328
+
329
+ # Plot: Crops in Nutrient-Poor Soil
330
+ less_avg_of_Climate_Factors = df[
331
+ (df['Temperature'] < avg_Temperature) &
332
+ (df['Humidity'] < avg_Humidity) &
333
+ (df['pH_Value'] < avg_pH_Value)&
334
+ (df['Rainfall'] < avg_Rainfall)
335
+ ]['Crop']
336
+
337
+ plot_climate_crops(less_avg_of_Climate_Factors, "Crops Growing in climate factors")
338
+
339
+ # Insights for Nutrient-Poor Crops
340
+ st.markdown("<h2 style='color: #D35400; font-size: 23px;'>Insights:</h2>", unsafe_allow_html=True)
341
+ st.markdown("""
342
+ <style>
343
+ .insights-box {
344
+ font-size: 19px;
345
+ color: #333;
346
+ background-color: #f9f9f9;
347
+ padding: 8px;
348
+ border-radius: 8px;
349
+ border-left: 4px solid #2E86C1;
350
+ }
351
+ </style>
352
+ <div class='insights-box'>
353
+ 1. Maize and Kidney Beans Grow Best :: These crops can grow well even in dry and less humid conditions with low rainfall. They are strong and can survive in tough climates.
354
+ 2.Chickpea and Lentil Grow Okay :: They can manage in dry conditions but need some care, like proper soil and water.
355
+ 3. Moth Beans and Pigeon Peas Struggle :: These crops don’t grow well in dry weather and need more rain and better soil.
356
  </div>
357
  """, unsafe_allow_html=True)