Practical (Data Science)
Practical (Data Science)
Performance &
Understanding
Exp
Signature of
&Participati
Submission
Submission
Attendance
(Out of 30)
.
Total
Teacher
Date of
Timely
No.
on
10 10 10 30
1 Create a pandas series from a
dictionary of values and an ndarray
Code:
import pandas as pd
import numpy as np
series_from_dict = pd.Series(dictionary)
print(series_from_dict)
series_from_ndarray = pd.Series(arr)
print(series_from_ndarray)
OUTPUT :
Practical – 2
2. Create a Series and print all the elements that are above 75th percentile.
Code:
import pandas as pd
import numpy as np
ser = pd.Series(arr)
quantile_value = ser.quantile(q=0.75)
print(val)
OUTPUT :
Practical-3
3. Perform sorting on Series data and DataFrames.
Code:
import pandas as pd
print(sorted_series)
Output:
Practical-4
4. Write a program to implement pivot() and pivot-table() on a DataFrame.
Code:
import pandas as pd
df = pd.DataFrame(data)
print(pivot_table)
Output:
Practical-5
5. Write a program to find mean absolute deviation on a DataFrame.
Code:
import pandas as pd
Output:
Practical-6
6. Create a DataFrame based on E Commerce data and generate mean, mode, median.
Code:
import pandas as pd
df = pd.DataFrame(data)
df = pd.DataFrame(data)
Output:
Practical-8
8. Write a program to create a DataFrame to store weight, age and name of three people.
Print the DataFrame and its transpose.
Code:
import pandas as pd
def average_temperature(temps):
return sum(temps) / len(temps)
avg_week1 = average_temperature(Temp1)
avg_week2 = average_temperature(Temp2)
avg_week3 = average_temperature(Temp3)
avg_week4 = average_temperature(Temp4)
# Initialize classifiers
xgb = XGBClassifier()
knn = KNeighborsClassifier()
ada = AdaBoostClassifier()
# Train classifiers
xgb.fit(X_train, y_train)
knn.fit(X_train, y_train)
ada.fit(X_train, y_train)
# Evaluate performance
y_pred_xgb = xgb.predict(X_test)
y_pred_knn = knn.predict(X_test)
y_pred_ada = ada.predict(X_test)
print(f"Precision: {precision:.2f}")
print(f"Recall: {recall:.2f}")
print(f"F1 Score: {f1:.2f}") Output: