Which plants are better for bees: native or non-native?
Introduction
This project was prepared for the local government environment agency and it covers creating pollinator bee-friendly spaces. The aim of the project was to analyze this data and provide recommendations on which plants create an optimized environment for pollinator bees.
💾 The Data
The assembled information on the plants and bees research in a file called plants_and_bees.csv. Each row represents a sample that was taken from a patch of land where the plant species were being studied.
| Column | Description |
|---|---|
sample_id | The ID number of the sample taken. |
bees_num | The total number of bee individuals in the sample. |
date | Date the sample was taken. |
season | Season during sample collection ("early.season" or "late.season"). |
site | Name of collection site. |
native_or_non | Whether the sample was from a native or non-native plot. |
sampling | The sampling method. |
plant_species | The name of the plant species the sample was taken from. None indicates the sample was taken from the air. |
time | The time the sample was taken. |
bee_species | The bee species in the sample. |
sex | The gender of the bee species. |
specialized_on | The plant genus the bee species preferred. |
parasitic | Whether or not the bee is parasitic (0:no, 1:yes). |
nesting | The bees nesting method. |
status | The status of the bee species. |
nonnative_bee | Whether the bee species is native or not (0:no, 1:yes). |
Source (data has been modified)
Data preparation and exploratary analysis
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
data = pd.read_csv('data/plants_and_bees.csv')
display(data.head(10))
print('data shape : ', data.shape)
print(data.describe())
print(data.info())#check counts of native and non-native plants
data['native_or_non'].value_counts()Let us first explore the missing values in the dataset and then plot their counts within individual columns.
missing_values = data.isna().sum() # number of missing values within individual columns
#print([miss_values, miss_value_prcnt])
sns.barplot(x = missing_values.index, y=missing_values.values, color = 'coral')
plt.xticks(rotation=70)
plt.show()We see that the most of the columns are complete, several values are in columns describing the nesting type, whether the bee species are parasitic and if the bee is native or non-native. On the other hand, the columns with specific specialization of bee species and their status is almost empty. We can now check, what 'status' cells contain non-empty values and what are they.
no_status_nans = data[~data['status'].isna()]
display(no_status_nans.loc[:,['sample_id','site', 'bee_species','plant_species', 'status']].sort_values('status'))Unfortunatelly, it was found out that all the vulnerable (IUCN) bees species samples were taken in the air, thus we can not determine which plants could contribute to the vulnerable bees populations. However, we can also observe that most of the vulnarable bees samples were taken at site 'A', which in turn may help us to compare relative significance of the sites in the further analysis.
no_specialized_on_nans = data[~data['specialized_on'].isna()]
display(no_specialized_on_nans.loc[:,['sample_id','site', 'bee_species','plant_species', 'specialized_on']].sort_values('specialized_on'))#print(data.loc[:, 'nonnative_bee'].value_counts(dropna=False))We also check what are the rest of the values when 'nonnative_bee' or 'parasitic' is null.
display(data[data['nonnative_bee'].isna()])