0% found this document useful (0 votes)
3 views2 pages

Sample Code

Uploaded by

suganthi s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Sample Code

Uploaded by

suganthi s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Step 1: Load Data

import pandas as pd

data = {
"Week": [1, 2, 3, 4, 1, 2, 3, 4],
"Height": [5, 8, 12, 15, 4, 7, 9, 11],
"Fertilizer": ["A", "A", "A", "A", "B", "B", "B", "B"]
}
df = pd.DataFrame(data)
df.head()

👉 First five rows of plant dataset:

Week Height Fertilizer


1 5 A
2 8 A
3 12 A
4 15 A
1 4 B

Step 2: Explore the Data


df.describe()

 Mean plant height = 8.9 cm


 Max plant height = 15 cm

Step 3: Compare Treatments


df.groupby("Fertilizer")["Height"].mean()

 Fertilizer A → 10.0 cm
 Fertilizer B → 7.75 cm

👉 Insight: Fertilizer A gave ~29% higher growth.

Step 4: Visualize
import seaborn as sns
import matplotlib.pyplot as plt

sns.lineplot(x="Week", y="Height", hue="Fertilizer", data=df, marker="o")


plt.title("Plant Growth Over Time (Fertilizer A vs B)")
plt.ylabel("Height (cm)")
plt.show()
📈 Result: Growth curve shows Fertilizer A plants consistently outgrew Fertilizer B.

You might also like