DjItVala 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- djitvala-0.1.0/DjItVala.egg-info/PKG-INFO +16 -0
- djitvala-0.1.0/DjItVala.egg-info/SOURCES.txt +22 -0
- djitvala-0.1.0/DjItVala.egg-info/dependency_links.txt +1 -0
- djitvala-0.1.0/DjItVala.egg-info/top_level.txt +2 -0
- djitvala-0.1.0/LICENCE +0 -0
- djitvala-0.1.0/MANIFEST.in +2 -0
- djitvala-0.1.0/PKG-INFO +16 -0
- djitvala-0.1.0/README.md +1 -0
- djitvala-0.1.0/demoit/__init__.py +0 -0
- djitvala-0.1.0/demoit/resource_loader.py +46 -0
- djitvala-0.1.0/demoit/resources/ClassificationModel.py +28 -0
- djitvala-0.1.0/demoit/resources/LogisticRegression.py +46 -0
- djitvala-0.1.0/demoit/resources/MONGODB.py +46 -0
- djitvala-0.1.0/demoit/resources/MultipleRegression.py +48 -0
- djitvala-0.1.0/demoit/resources/SVM.py +20 -0
- djitvala-0.1.0/demoit/resources/cluster(a).py +29 -0
- djitvala-0.1.0/demoit/resources/desicion_tree.py +41 -0
- djitvala-0.1.0/demoit/resources/mapreduced(weather).py +34 -0
- djitvala-0.1.0/demoit/resources/mapreduced(wordcount).py +26 -0
- djitvala-0.1.0/demoit/resources/titanic_analysis (1).py +74 -0
- djitvala-0.1.0/demoit/resources/titanic_analysis.py +0 -0
- djitvala-0.1.0/pyproject.toml +30 -0
- djitvala-0.1.0/setup.cfg +4 -0
- djitvala-0.1.0/setup.py +10 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: DjItVala
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: My first Python package
|
|
5
|
+
Author: Demo IT Vala
|
|
6
|
+
Author-email: DjItVala <youremail@example.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/yourusername/my-package
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENCE
|
|
12
|
+
Dynamic: author
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
|
|
16
|
+
This is a python package containing py codes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
LICENCE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
DjItVala.egg-info/PKG-INFO
|
|
7
|
+
DjItVala.egg-info/SOURCES.txt
|
|
8
|
+
DjItVala.egg-info/dependency_links.txt
|
|
9
|
+
DjItVala.egg-info/top_level.txt
|
|
10
|
+
demoit/__init__.py
|
|
11
|
+
demoit/resource_loader.py
|
|
12
|
+
demoit/resources/ClassificationModel.py
|
|
13
|
+
demoit/resources/LogisticRegression.py
|
|
14
|
+
demoit/resources/MONGODB.py
|
|
15
|
+
demoit/resources/MultipleRegression.py
|
|
16
|
+
demoit/resources/SVM.py
|
|
17
|
+
demoit/resources/cluster(a).py
|
|
18
|
+
demoit/resources/desicion_tree.py
|
|
19
|
+
demoit/resources/mapreduced(weather).py
|
|
20
|
+
demoit/resources/mapreduced(wordcount).py
|
|
21
|
+
demoit/resources/titanic_analysis (1).py
|
|
22
|
+
demoit/resources/titanic_analysis.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
djitvala-0.1.0/LICENCE
ADDED
|
File without changes
|
djitvala-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: DjItVala
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: My first Python package
|
|
5
|
+
Author: Demo IT Vala
|
|
6
|
+
Author-email: DjItVala <youremail@example.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/yourusername/my-package
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENCE
|
|
12
|
+
Dynamic: author
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
|
|
16
|
+
This is a python package containing py codes
|
djitvala-0.1.0/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a python package containing py codes
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from importlib.resources import files
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
# Base resources directory
|
|
5
|
+
BASE_RESOURCES = files("DjItVala") / "resources"
|
|
6
|
+
|
|
7
|
+
ALLOWED_EXTENSIONS = (".py", ".csv")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_file(category: str, filename: str) -> Path:
|
|
11
|
+
"""
|
|
12
|
+
Get a specific PY or CSV file from a category.
|
|
13
|
+
category: 'data_science' or 'soft_computing'
|
|
14
|
+
"""
|
|
15
|
+
if not filename.endswith(ALLOWED_EXTENSIONS):
|
|
16
|
+
raise ValueError("Only .py and .csv files are allowed")
|
|
17
|
+
|
|
18
|
+
return BASE_RESOURCES / category / filename
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def list_files(category: str) -> list[Path]:
|
|
22
|
+
"""
|
|
23
|
+
List all PY and CSV files in a category.
|
|
24
|
+
"""
|
|
25
|
+
directory = BASE_RESOURCES / category
|
|
26
|
+
return [p for p in directory.iterdir() if p.suffix in ALLOWED_EXTENSIONS]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def load_csv(filename: str, category: str = "data_science") -> str:
|
|
30
|
+
"""
|
|
31
|
+
Read a CSV file and return its content as text.
|
|
32
|
+
"""
|
|
33
|
+
path = get_file(category, filename)
|
|
34
|
+
|
|
35
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
36
|
+
return f.read()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def load_py(filename: str, category: str = "soft_computing") -> str:
|
|
40
|
+
"""
|
|
41
|
+
Read a PY file and return its code as text.
|
|
42
|
+
"""
|
|
43
|
+
path = get_file(category, filename)
|
|
44
|
+
|
|
45
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
46
|
+
return f.read()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from sklearn.tree import DecisionTreeClassifier
|
|
2
|
+
|
|
3
|
+
# Student Names
|
|
4
|
+
students = ["Sam", "Nidhi", "Tejas", "Ricky", "Sai",
|
|
5
|
+
"Kamlii", "vinay", "Dharmesh", "Mitu", "Roma"]
|
|
6
|
+
|
|
7
|
+
# Features: [Marks, Attendance]
|
|
8
|
+
X = [[35,60],[40,65],[75,85],[80,90],[55,70],
|
|
9
|
+
[30,50],[90,95],[45,60],[70,80],[25,40]]
|
|
10
|
+
|
|
11
|
+
# Target
|
|
12
|
+
y = ["Fail","Fail","Pass","Pass","Pass",
|
|
13
|
+
"Fail","Pass","Fail","Pass","Fail"]
|
|
14
|
+
|
|
15
|
+
# Train Classifier
|
|
16
|
+
dt = DecisionTreeClassifier()
|
|
17
|
+
dt.fit(X, y)
|
|
18
|
+
|
|
19
|
+
# Predict result for a new student
|
|
20
|
+
student_name = "Sam"
|
|
21
|
+
new_student = [[75, 80]] # Marks, Attendance
|
|
22
|
+
|
|
23
|
+
result = dt.predict(new_student)
|
|
24
|
+
|
|
25
|
+
print("Student Name :", student_name)
|
|
26
|
+
print("Marks :", new_student[0][0])
|
|
27
|
+
print("Attendance :", new_student[0][1], "%")
|
|
28
|
+
print("Prediction :", result[0])
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Import libraries
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from sklearn.linear_model import LogisticRegression
|
|
4
|
+
|
|
5
|
+
# Create dataset
|
|
6
|
+
data = {
|
|
7
|
+
"Name": ["Sam", "Nidhi", "Tejas", "Ricky", "Sai"],
|
|
8
|
+
"GRE": [750, 600, 700, 500, 650],
|
|
9
|
+
"GPA": [3.8, 3.2, 3.6, 2.8, 3.4],
|
|
10
|
+
"Rank": [1, 2, 1, 4, 3],
|
|
11
|
+
"Admit": [1, 1, 1, 0, 0]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
df = pd.DataFrame(data)
|
|
15
|
+
|
|
16
|
+
# Features and target
|
|
17
|
+
X = df[["GRE", "GPA", "Rank"]]
|
|
18
|
+
y = df["Admit"]
|
|
19
|
+
|
|
20
|
+
# Train model
|
|
21
|
+
model = LogisticRegression()
|
|
22
|
+
model.fit(X, y)
|
|
23
|
+
|
|
24
|
+
# Input new student details
|
|
25
|
+
name = input("Enter Student Name: ")
|
|
26
|
+
gre = int(input("Enter GRE Score: "))
|
|
27
|
+
gpa = float(input("Enter GPA: "))
|
|
28
|
+
rank = int(input("Enter College Rank (1-4): "))
|
|
29
|
+
|
|
30
|
+
# Create DataFrame for prediction
|
|
31
|
+
new_student = pd.DataFrame({
|
|
32
|
+
"GRE": [gre],
|
|
33
|
+
"GPA": [gpa],
|
|
34
|
+
"Rank": [rank]
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
# Predict admission
|
|
38
|
+
result = model.predict(new_student)
|
|
39
|
+
|
|
40
|
+
# Display result
|
|
41
|
+
print("\nStudent Name:", name)
|
|
42
|
+
|
|
43
|
+
if result[0] == 1:
|
|
44
|
+
print("Admission Status: Admitted")
|
|
45
|
+
else:
|
|
46
|
+
print("Admission Status: Not Admitted")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from pymongo import MongoClient
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
client = MongoClient("mongodb://localhost:27017/")
|
|
5
|
+
db = client["BigDataDB"]
|
|
6
|
+
collection = db["StudentData"]
|
|
7
|
+
|
|
8
|
+
df = pd.read_csv("students.csv")
|
|
9
|
+
|
|
10
|
+
print("\nOriginal CSV Data:\n")
|
|
11
|
+
print(df)
|
|
12
|
+
|
|
13
|
+
data = df.to_dict(orient="records")
|
|
14
|
+
|
|
15
|
+
collection.delete_many({})
|
|
16
|
+
|
|
17
|
+
collection.insert_many(data)
|
|
18
|
+
|
|
19
|
+
print("\nCSV Data Inserted into MongoDB Successfully\n")
|
|
20
|
+
|
|
21
|
+
records = list(collection.find())
|
|
22
|
+
|
|
23
|
+
mongo_df = pd.DataFrame(records)
|
|
24
|
+
|
|
25
|
+
mongo_df = mongo_df.drop(columns=["_id"])
|
|
26
|
+
|
|
27
|
+
print("Data Read From MongoDB:\n")
|
|
28
|
+
print(mongo_df)
|
|
29
|
+
mongo_df["Marks"] = mongo_df["Marks"] + 5
|
|
30
|
+
filtered = mongo_df[mongo_df["Marks"] > 85]
|
|
31
|
+
sorted_data = filtered.sort_values(by="Marks", ascending=False)
|
|
32
|
+
print("\nManipulated Data:\n")
|
|
33
|
+
print(sorted_data)
|
|
34
|
+
|
|
35
|
+
for index, row in sorted_data.iterrows():
|
|
36
|
+
collection.update_one(
|
|
37
|
+
{"Name": row["Name"]},
|
|
38
|
+
{"$set": {"Marks": int(row["Marks"])}}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
print("\nMongoDB Updated Successfully\n")
|
|
42
|
+
|
|
43
|
+
print("Final Data From MongoDB:\n")
|
|
44
|
+
|
|
45
|
+
for record in collection.find({}, {"_id": 0}):
|
|
46
|
+
print(record)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from sklearn.linear_model import LinearRegression
|
|
2
|
+
|
|
3
|
+
# Student Names
|
|
4
|
+
students = ["Sam", "Nidhi", "Tejas", "Ricky", "sai",
|
|
5
|
+
"Kamlesh", "Vinay", "Dharmesh", "Mitu", "Roma"]
|
|
6
|
+
|
|
7
|
+
# Features: [Study Hours, Attendance]
|
|
8
|
+
X = [
|
|
9
|
+
[3,60],
|
|
10
|
+
[3,65],
|
|
11
|
+
[6,85],
|
|
12
|
+
[7,90],
|
|
13
|
+
[5,70],
|
|
14
|
+
[1,50],
|
|
15
|
+
[8,95],
|
|
16
|
+
[3,60],
|
|
17
|
+
[6,80],
|
|
18
|
+
[1,40]
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
# Final Marks
|
|
22
|
+
y = [80,90,45,80,55,30,20,45,30,25]
|
|
23
|
+
|
|
24
|
+
# Train Model
|
|
25
|
+
model = LinearRegression()
|
|
26
|
+
model.fit(X, y)
|
|
27
|
+
|
|
28
|
+
# Display existing students and results
|
|
29
|
+
print("Student Results")
|
|
30
|
+
print("-" * 40)
|
|
31
|
+
|
|
32
|
+
for i in range(len(students)):
|
|
33
|
+
result = "Pass" if y[i] >= 40 else "Fail"
|
|
34
|
+
print(students[i], "- Marks:", y[i], "-", result)
|
|
35
|
+
|
|
36
|
+
# Predict for a new student
|
|
37
|
+
new_student_name = "Nidhi"
|
|
38
|
+
new_student = [[4,75]]
|
|
39
|
+
|
|
40
|
+
predicted_marks = model.predict(new_student)[0]
|
|
41
|
+
|
|
42
|
+
result = "Pass" if predicted_marks >= 40 else "Fail"
|
|
43
|
+
|
|
44
|
+
print("\nNew Student Prediction")
|
|
45
|
+
print("-" * 40)
|
|
46
|
+
print("Name:", new_student_name)
|
|
47
|
+
print("Predicted Marks:", round(predicted_marks, 2))
|
|
48
|
+
print("Result:", result)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from sklearn.svm import SVC
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
x = [[80,20],[65,25],[40,60],[65,45],[85,95]]
|
|
5
|
+
y = ["Pass","Fail","Pass","Fail","Pass"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
model = SVC()
|
|
9
|
+
model.fit(x, y)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Name = input("Enter your Name: ")
|
|
13
|
+
Marks = int(input("Enter your Marks: "))
|
|
14
|
+
Attendance = int(input("Enter your Attendance: "))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
result = model.predict([[Marks, Attendance]])
|
|
18
|
+
|
|
19
|
+
print("Name:", Name)
|
|
20
|
+
print("Result:", result[0])
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Simple K-Means Clustering
|
|
2
|
+
|
|
3
|
+
from sklearn.cluster import KMeans
|
|
4
|
+
import pandas as pd
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
|
|
7
|
+
# Student Marks
|
|
8
|
+
marks = [35, 40, 45, 50, 75, 80, 85, 90]
|
|
9
|
+
|
|
10
|
+
# Create DataFrame
|
|
11
|
+
df = pd.DataFrame({'Marks': marks})
|
|
12
|
+
|
|
13
|
+
# Apply K-Means
|
|
14
|
+
model = KMeans(n_clusters=2)
|
|
15
|
+
|
|
16
|
+
# Create Clusters
|
|
17
|
+
df['Cluster'] = model.fit_predict(df)
|
|
18
|
+
|
|
19
|
+
# Print Output
|
|
20
|
+
print(df)
|
|
21
|
+
|
|
22
|
+
# Plot Graph
|
|
23
|
+
plt.scatter(df['Marks'], df['Cluster'])
|
|
24
|
+
|
|
25
|
+
plt.xlabel("Marks")
|
|
26
|
+
plt.ylabel("Cluster")
|
|
27
|
+
plt.title("Student Clustering")
|
|
28
|
+
|
|
29
|
+
plt.show()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Simple Decision Tree Program
|
|
2
|
+
|
|
3
|
+
from sklearn.tree import DecisionTreeClassifier
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
# -----------------------------
|
|
7
|
+
# Student Data
|
|
8
|
+
# -----------------------------
|
|
9
|
+
data = {
|
|
10
|
+
'Marks': [35, 90, 40, 85, 30, 75],
|
|
11
|
+
'Result': ['Fail', 'Pass', 'Fail', 'Pass', 'Fail', 'Pass']
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Create DataFrame
|
|
15
|
+
df = pd.DataFrame(data)
|
|
16
|
+
|
|
17
|
+
# Input and Output
|
|
18
|
+
X = df[['Marks']]
|
|
19
|
+
y = df['Result']
|
|
20
|
+
|
|
21
|
+
# Train Model
|
|
22
|
+
model = DecisionTreeClassifier()
|
|
23
|
+
model.fit(X, y)
|
|
24
|
+
|
|
25
|
+
# Predict New Student
|
|
26
|
+
new_student = pd.DataFrame({'Marks': [70]})
|
|
27
|
+
|
|
28
|
+
prediction = model.predict(new_student)
|
|
29
|
+
|
|
30
|
+
print("Prediction:", prediction[0])
|
|
31
|
+
|
|
32
|
+
# -----------------------------
|
|
33
|
+
# Simple Text Decision Tree
|
|
34
|
+
# -----------------------------
|
|
35
|
+
print("\nDecision Tree:\n")
|
|
36
|
+
|
|
37
|
+
print(" Marks <= 50")
|
|
38
|
+
print(" / \\")
|
|
39
|
+
print(" True False")
|
|
40
|
+
print(" / \\")
|
|
41
|
+
print(" Result = Fail Result = Pass")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
# Read weather dataset
|
|
4
|
+
data = pd.read_csv("weather(3).csv")
|
|
5
|
+
|
|
6
|
+
# MAP PHASE
|
|
7
|
+
print("MAP OUTPUT")
|
|
8
|
+
mapped_data = []
|
|
9
|
+
|
|
10
|
+
for index, row in data.iterrows():
|
|
11
|
+
city = row["City"]
|
|
12
|
+
temp = row["Temperature"]
|
|
13
|
+
|
|
14
|
+
mapped_data.append((city, temp))
|
|
15
|
+
print((city, temp))
|
|
16
|
+
|
|
17
|
+
# REDUCE PHASE
|
|
18
|
+
print("\nREDUCE OUTPUT")
|
|
19
|
+
|
|
20
|
+
city_temp = {}
|
|
21
|
+
|
|
22
|
+
for city, temp in mapped_data:
|
|
23
|
+
|
|
24
|
+
if city not in city_temp:
|
|
25
|
+
city_temp[city] = []
|
|
26
|
+
|
|
27
|
+
city_temp[city].append(temp)
|
|
28
|
+
|
|
29
|
+
# Calculate average temperature
|
|
30
|
+
for city in city_temp:
|
|
31
|
+
|
|
32
|
+
avg_temp = sum(city_temp[city]) / len(city_temp[city])
|
|
33
|
+
|
|
34
|
+
print(city, "Average Temperature =", avg_temp)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Word Count / Frequency Count using MapReduce
|
|
2
|
+
|
|
3
|
+
# User Input
|
|
4
|
+
text = input("Enter a sentence: ")
|
|
5
|
+
|
|
6
|
+
# MAP PHASE
|
|
7
|
+
print("\nMAP OUTPUT")
|
|
8
|
+
mapped_data = []
|
|
9
|
+
|
|
10
|
+
words = text.split()
|
|
11
|
+
|
|
12
|
+
for word in words:
|
|
13
|
+
pair = (word.lower(), 1)
|
|
14
|
+
mapped_data.append(pair)
|
|
15
|
+
print(pair)
|
|
16
|
+
|
|
17
|
+
# REDUCE PHASE
|
|
18
|
+
print("\nREDUCE OUTPUT (Word Frequency Count)")
|
|
19
|
+
|
|
20
|
+
word_count = {}
|
|
21
|
+
|
|
22
|
+
for word, count in mapped_data:
|
|
23
|
+
word_count[word] = word_count.get(word, 0) + count
|
|
24
|
+
|
|
25
|
+
for word, total in word_count.items():
|
|
26
|
+
print(word, ":", total)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from pymongo import MongoClient
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Connect MongoDB
|
|
6
|
+
|
|
7
|
+
client = MongoClient(
|
|
8
|
+
"mongodb://localhost:27017/"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
db = client["bigdata"]
|
|
13
|
+
|
|
14
|
+
collection = db["titanic"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Count total records
|
|
19
|
+
|
|
20
|
+
count = collection.count_documents({})
|
|
21
|
+
|
|
22
|
+
print("Total Passengers:", count)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Display first 5 records
|
|
27
|
+
|
|
28
|
+
print("\nFirst 5 Records")
|
|
29
|
+
|
|
30
|
+
for data in collection.find().limit(5):
|
|
31
|
+
print(data)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# Find survived passengers
|
|
36
|
+
|
|
37
|
+
print("\nSurvived Passengers")
|
|
38
|
+
|
|
39
|
+
survived = collection.find(
|
|
40
|
+
{
|
|
41
|
+
"Survived":1
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
for passenger in survived.limit(10):
|
|
47
|
+
print(passenger["Name"])
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Average age
|
|
52
|
+
|
|
53
|
+
pipeline = [
|
|
54
|
+
{
|
|
55
|
+
"$group":
|
|
56
|
+
{
|
|
57
|
+
"_id":None,
|
|
58
|
+
"average_age":
|
|
59
|
+
{
|
|
60
|
+
"$avg":"$Age"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
result = collection.aggregate(pipeline)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
for r in result:
|
|
71
|
+
print(
|
|
72
|
+
"\nAverage Age:",
|
|
73
|
+
r["average_age"]
|
|
74
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "DjItVala"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "My first Python package"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "DjItVala", email = "youremail@example.com"}
|
|
14
|
+
]
|
|
15
|
+
dependencies = []
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/yourusername/my-package"
|
|
19
|
+
|
|
20
|
+
[tool.setuptools]
|
|
21
|
+
include-package-data = true
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["."]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.package-data]
|
|
27
|
+
DjItVala = [
|
|
28
|
+
"resources/*.csv",
|
|
29
|
+
"resources/*.py"
|
|
30
|
+
]
|
djitvala-0.1.0/setup.cfg
ADDED