├── Array-To-Float.py ├── College.py ├── Data-Anallitics.py ├── EXCEL-To-Json-File.py ├── Employes-Details.py ├── HR-Array-Float.py ├── IVList-cse.py ├── Matrix Multiplicatio-numpy.py ├── Matrix.py ├── Mean-SD-numpy.py ├── Mobile-Details.py ├── Panda,py ├── Randomnumber-numpy.py ├── Students-Details.py ├── Uses-0f-NumPy.py ├── Using-numpy.py └── img-procesing-numpy.py /Array-To-Float.py: -------------------------------------------------------------------------------- 1 | import numpy as tony 2 | 3 | array1=tony.array([1,2,3,4,5]) 4 | float_array=array1.astype('float') 5 | x=len(array1) 6 | print("the length is",x) 7 | print("the array is succesfully converted into Float") 8 | printt(float_array) 9 | -------------------------------------------------------------------------------- /College.py: -------------------------------------------------------------------------------- 1 | #CALCULATING STUDENTS JOINED IN MY COLLEGE USING PANDAS IN PYTHON 2 | import pandas as pd 3 | 4 | # Sample student data with 'Department' column 5 | data = { 6 | 'StudentID': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 7 | 'Name': ['Student1', 'Student2', 'Student3', 'Student4', 'Student5', 'Student6', 'Student7', 'Student8', 'Student9', 'Student10'], 8 | 'Department': ['CSE', 'MECH', 'CIVIL', 'EEE', 'CSE', 'ECE', 'CSE', 'MECH', 'EEE', 'CIVIL'] 9 | } 10 | 11 | # Create a DataFrame from the sample data 12 | df = pd.DataFrame(data) 13 | 14 | # Calculate the number of students in each department 15 | department_counts = df['Department'].value_counts() 16 | 17 | # Display the results 18 | print("STELLA MARYS COLLEGE OF ENGINEERING") 19 | print("Number of students joined each department:") 20 | print(department_counts) 21 | -------------------------------------------------------------------------------- /Data-Anallitics.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | # Load data from a CSV file into a DataFrame 4 | data = pd.read_csv('sample_data.csv') # Replace 'sample_data.csv' with your CSV file 5 | 6 | # Display the first few rows of the DataFrame 7 | print("First few rows of the DataFrame:") 8 | print(data.head()) 9 | 10 | # Display basic statistics of numeric columns 11 | print("\nSummary statistics:") 12 | print(data.describe()) 13 | 14 | # Filter data based on a condition 15 | young_employees = data[data['Age'] < 30] 16 | print("\nYoung employees:") 17 | print(young_employees) 18 | 19 | # Group and aggregate datA 20 | average_salary_by_age = data.groupby('Age')['Salary'].mean() 21 | print("\nAverage salary by age:") 22 | print(average_salary_by_age) 23 | -------------------------------------------------------------------------------- /EXCEL-To-Json-File.py: -------------------------------------------------------------------------------- 1 | You can convert an Excel file into a JSON file using the Pandas library in Python. Here's a step-by-step guide to do this: 2 | 3 | Install Pandas and Openpyxl (if not already installed): 4 | If you haven't already installed Pandas and the Openpyxl library, you can do so using pip: 5 | 6 | 7 | pip install pandas openpyxl 8 | 9 | 10 | 11 | Read the Excel File: 12 | Use Pandas to read the Excel file and load it into a DataFrame. Make sure to specify the sheet name if your Excel file has multiple sheets. 13 | 14 | 15 | import pandas as pd 16 | 17 | # Replace 'your_excel_file.xlsx' with the path to your Excel file 18 | df = pd.read_excel('your_excel_file.xlsx', sheet_name='Sheet1') 19 | 20 | 21 | 22 | Convert DataFrame to JSON: 23 | Use the to_json method of the DataFrame to convert it into a JSON string. You can customize the format and orientation of the JSON as needed. 24 | 25 | 26 | # Convert DataFrame to JSON (orient 'records' for a list of dictionaries) 27 | json_data = df.to_json(orient='records', indent=4) 28 | 29 | 30 | 31 | Save JSON to a File: 32 | Finally, you can save the JSON data to a file using Python's built-in file handling methods. 33 | 34 | # Save JSON to a file (replace 'output.json' with your desired filename) 35 | with open('output.json', 'w') as json_file: 36 | json_file.write(json_data) 37 | 38 | 39 | 40 | 41 | Here's the complete code: 42 | --------------------------- 43 | 44 | 45 | 46 | 47 | import pandas as pd 48 | 49 | # Read the Excel file into a DataFrame 50 | df = pd.read_excel('your_excel_file.xlsx', sheet_name='Sheet1') 51 | 52 | # Convert the DataFrame to JSON 53 | json_data = df.to_json(orient='records', indent=4) 54 | 55 | # Save the JSON to a file 56 | with open('output.json', 'w') as json_file: 57 | json_file.write(json_data) 58 | -------------------------------------------------------------------------------- /Employes-Details.py: -------------------------------------------------------------------------------- 1 | #employe details 2 | import pandas as pd 3 | 4 | # Sample data for employee details 5 | data = { 6 | 'Employee ID': [101, 102, 103, 104, 105], 7 | 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva'], 8 | 'Age': [30, 28, 35, 25, 32], 9 | 'Department': ['HR', 'IT', 'Sales', 'Finance', 'Marketing'], 10 | 'Salary': [55000, 60000, 48000, 75000, 52000], 11 | } 12 | 13 | # Create a DataFrame from the data 14 | df = pd.DataFrame(data) 15 | 16 | # Display the employee details 17 | print("Employee Details:") 18 | print(df) 19 | -------------------------------------------------------------------------------- /HR-Array-Float.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | np.set_printoptions(legacy='1.13') 3 | 4 | # Read input values 5 | n, m = map(int, input().split()) 6 | 7 | # Create the desired N X M array with 's on the main diagonal 8 | x_array = np.eye(n, m) 9 | 10 | # Print the N X M array 11 | print(x_array) 12 | -------------------------------------------------------------------------------- /IVList-cse.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import random 3 | 4 | # Function to generate random student data 5 | def generate_student_data(n): 6 | data = { 7 | 'StudentID': range(1, n + 1), 8 | 'Name': ['Student' + str(i) for i in range(1, n + 1)], 9 | 'Department': [random.choice(['CSE', 'MECH', 'CIVIL', 'EEE', 'ECE']) for _ in range(n)], 10 | 'IV_Coming': [random.choice([True, False]) for _ in range(n)] 11 | } 12 | return data 13 | 14 | # Number of students to generate 15 | n = 50 # You can change this to generate data for any number of students 16 | 17 | # Create a DataFrame with random student data 18 | student_data = generate_student_data(n) 19 | df = pd.DataFrame(student_data) 20 | 21 | # Filter students who are coming for IV in the CSE department 22 | cse_iv_students = df[(df['Department'] == 'CSE') & (df['IV_Coming'] == True)] 23 | 24 | # Display the students coming for IV in the CSE department 25 | print("Created by Infance Tony") 26 | print("Students in CSE coming for IV:") 27 | print(cse_iv_students[['StudentID', 'Name']]) 28 | -------------------------------------------------------------------------------- /Matrix Multiplicatio-numpy.py: -------------------------------------------------------------------------------- 1 | 2 | #2X2 Matrix 3 | 4 | 5 | import numpy as np 6 | 7 | # Create two matrices 8 | matrix1 = np.array([[1, 2], [3, 4]]) 9 | matrix2 = np.array([[5, 6], [7, 8]]) 10 | 11 | # Multiply the matrices 12 | result_matrix = np.dot(matrix1, matrix2) 13 | 14 | # Display the result 15 | print("Result Matrix:") 16 | print(result_matrix) 17 | -------------------------------------------------------------------------------- /Matrix.py: -------------------------------------------------------------------------------- 1 | import numpy as tony 2 | 3 | array1=tony.array([[1,2,3,],[4,5,6],[7,8,9]]) 4 | x=len(array1) 5 | print(array1) 6 | print(x) 7 | -------------------------------------------------------------------------------- /Mean-SD-numpy.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | # Create an array of test scores 4 | scores = np.array([85, 90, 78, 92, 88]) 5 | 6 | # Calculate the mean and standard deviation 7 | mean_score = np.mean(scores) 8 | std_deviation = np.std(scores) 9 | 10 | # Display the results 11 | print("Mean Score:", mean_score) 12 | print("Standard Deviation:", std_deviation) 13 | -------------------------------------------------------------------------------- /Mobile-Details.py: -------------------------------------------------------------------------------- 1 | # MOBILE DETAILS USING PANDA LIBRARY FUNCTION 2 | import pandas as pd 3 | import random 4 | 5 | # Sample data for mobile phones in INR 6 | data = { 7 | 'Brand': ['Apple', 'Samsung', 'Google', 'OnePlus', 'Xiaomi'], 8 | 'Model': ['iPhone X', 'Galaxy S21', 'Pixel 6', 'OnePlus 9 Pro', 'Mi 11'], 9 | 'Price (INR)': [random.randint(20000, 100000) for _ in range(5)], 10 | 'Specifications': [ 11 | '6.1" OLED, 128GB storage, Dual-camera', 12 | '6.2" AMOLED, 256GB storage, Triple-camera', 13 | '6.0" OLED, 128GB storage, Dual-camera', 14 | '6.7" Fluid AMOLED, 256GB storage, Quad-camera', 15 | '6.81" AMOLED, 128GB storage, Triple-camera' 16 | ] 17 | } 18 | 19 | # Create a DataFrame from the data 20 | df = pd.DataFrame(data) 21 | 22 | # Display the mobile phone details 23 | print("Mobile Phone Details:") 24 | print(df) 25 | -------------------------------------------------------------------------------- /Panda,py: -------------------------------------------------------------------------------- 1 | # DataScience-Python 2 | #USING PANDAS LIBRARY FUNCTION IN PYTHON 3 | import pandas as pd 4 | 5 | # Sample dataset (you can replace this with your own dataset) 6 | data = { 7 | 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva'], 8 | 'Age': [25, 30, 22, 35, 28], 9 | 'Salary': [50000, 60000, 48000, 75000, 52000], 10 | } 11 | 12 | # Create a DataFrame from the dataset 13 | df = pd.DataFrame(data) 14 | 15 | # Display the first few rows of the dataset 16 | print("DataFrame:") 17 | print(df) 18 | print() 19 | 20 | # Summary statistics 21 | print("Summary Statistics:") 22 | print(df.describe()) 23 | print() 24 | 25 | # Filter data 26 | print("Filtering Data:") 27 | young_employees = df[df['Age'] < 30] 28 | print(young_employees) 29 | print() 30 | 31 | # Grouping and aggregation 32 | print("Grouping and Aggregation:") 33 | average_salary_by_age = df.groupby('Age')['Salary'].mean() 34 | print(average_salary_by_age) 35 | -------------------------------------------------------------------------------- /Randomnumber-numpy.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | # Generate an array of 5 random integers between 1 and 10 4 | random_numbers = np.random.randint(1, 11, 5) 5 | 6 | # Display the random numbers 7 | print("Random Numbers:", random_numbers) 8 | -------------------------------------------------------------------------------- /Students-Details.py: -------------------------------------------------------------------------------- 1 | #students details 2 | import pandas as pd 3 | import random 4 | 5 | # Sample data for student details 6 | data = { 7 | 'Name': ['Student 1', 'Student 2', 'Student 3', 'Student 4', 'Student 5'], 8 | 'Age': [random.randint(18, 25) for _ in range(5)], 9 | 'Gender': ['Male', 'Female', 'Female', 'Male', 'Female'], 10 | 'Course': ['Mathematics', 'History', 'Physics', 'Chemistry', 'Biology'], 11 | 'Roll Number': [random.randint(1001, 9999) for _ in range(5)] 12 | } 13 | 14 | # Create a DataFrame from the data 15 | df = pd.DataFrame(data) 16 | 17 | # Display the student details 18 | print("Student Details:") 19 | print(df) 20 | -------------------------------------------------------------------------------- /Uses-0f-NumPy.py: -------------------------------------------------------------------------------- 1 | NumPy is a powerful library for numerical and scientific computing in Python. Here are some common tasks and operations you can perform using NumPy: 2 | 3 | Creating Arrays: NumPy allows you to create arrays of various shapes and sizes, including 1D arrays (vectors), 2D arrays (matrices), and multi-dimensional arrays. 4 | 5 | Array Operations: You can perform various operations on NumPy arrays, including element-wise arithmetic operations, broadcasting, and matrix operations like dot products and matrix multiplication. 6 | 7 | Mathematical Functions: NumPy provides a wide range of mathematical functions, such as trigonometric functions, logarithmic functions, exponential functions, and statistical functions. 8 | 9 | Random Number Generation: NumPy has functions for generating random numbers and random arrays, which are useful for simulations, statistical analysis, and machine learning. 10 | 11 | Indexing and Slicing: You can access and manipulate individual elements or slices of arrays using indexing and slicing. 12 | 13 | Reshaping Arrays: NumPy allows you to change the shape of arrays, which can be useful for data transformation and preparing data for various operations. 14 | 15 | Aggregation and Statistics: You can calculate various statistics on arrays, including mean, median, variance, standard deviation, and more. 16 | 17 | Linear Algebra: NumPy provides a rich set of linear algebra functions, including solving linear equations, eigenvalue calculations, singular value decomposition (SVD), and matrix factorization. 18 | 19 | Data Filtering: You can filter and manipulate data in arrays based on conditions, making it useful for data preprocessing and cleaning. 20 | 21 | Data Integration: NumPy can be integrated with other libraries and tools for data analysis and visualization, such as Matplotlib, Pandas, and SciPy. 22 | 23 | Signal Processing: NumPy has functions for signal processing tasks like Fourier transforms, convolution, and filtering. 24 | 25 | Image Processing: It can be used for basic image processing tasks, such as loading, manipulating, and saving images. 26 | 27 | Optimization: You can use NumPy for numerical optimization, including linear programming and nonlinear optimization problems. 28 | 29 | Machine Learning: NumPy is a fundamental library in many machine learning frameworks like scikit-learn, TensorFlow, and PyTorch, where it's used for handling data and mathematical operations. 30 | 31 | Simulation: You can use NumPy for simulating various scenarios and experiments in fields like physics, economics, and engineering. 32 | 33 | Overall, NumPy is an essential library for data scientists, researchers, engineers, and anyone working with numerical data in Python. Its versatility and efficiency make it a valuable tool for a wide range of scientific and engineering applications. 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Using-numpy.py: -------------------------------------------------------------------------------- 1 | #unsing numpy library 2 | import numpy as np 3 | 4 | # Create a NumPy array from a list of numbers 5 | my_array = np.array([1, 2, 3, 4, 5]) 6 | 7 | # Display the array 8 | print("NumPy Array:") 9 | print(my_array) 10 | 11 | # Calculate the mean of the elements 12 | mean_value = np.mean(my_array) 13 | 14 | # Multiply all elements by 2 15 | doubled_array = my_array * 2 16 | 17 | # Display the results 18 | print("\nMean Value:", mean_value) 19 | print("\nDoubled Array:") 20 | print(doubled_array) 21 | -------------------------------------------------------------------------------- /img-procesing-numpy.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from PIL import Image 4 | 5 | # Load an image 6 | image = Image.open('sample.jpg') 7 | 8 | # Convert the image to a NumPy array 9 | img_array = np.array(image) 10 | 11 | # Convert the image to grayscale 12 | grayscale_array = np.mean(img_array, axis=2).astype(np.uint8) 13 | 14 | # Display the grayscale image 15 | plt.imshow(grayscale_array, cmap='gray') 16 | plt.axis('off') 17 | plt.show() 18 | --------------------------------------------------------------------------------