×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Create a Program to Implement Pandas Dataframe in Python Assignment Solution

July 09, 2024
Dr. Sophia Nguyen
Dr. Sophia
🇸🇬 Singapore
Python
Dr. Sophia Nguyen holds a Doctorate in Computer Engineering from an esteemed university in Singapore and has completed over 900 assignments in Python file handling. Dr. Nguyen's expertise spans across areas such as file I/O optimizations, concurrency in file operations, and developing scalable file management systems. She excels in handling large datasets, implementing efficient error recovery strategies, and integrating file operations into web applications.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Ensure you understand the dataset thoroughly before starting your machine learning assignment. Visualize the data, check for missing values, and identify patterns or anomalies to guide your model-building process effectively.
News
In 2024, universities have introduced new programming courses focusing on cybersecurity, machine learning, and artificial intelligence to better prepare students for modern IT careers.

Instructions

Objective

Write a program to implement pandas dataframe in python language.

Requirements and Specifications

Description

  1. Write a Python assignment program that reads the CSV file into a Panda dataframe. Using that dataframe, print the row, source IP, and destination IP as a table.
  2. Write a python program that reads the CSV file into an ArrayList. Convert the ArrayList to a string array and print the row, source IP, and destination IP on the same line using a loop. Place your screenshots and responses in a Microsoft Word document. Be sure to include the .python files with your code for the python portions.

Source Code

import pandas as pd import csv if __name__ == '__main__': # Open file data = list() with open('IN300_Dataset1.csv', 'r') as f: lines = f.readlines() for i, line in enumerate(lines): # ignore first line if i == 0: continue # Remove all quotation marks #line = line.replace('"', '') line = line.strip() # Now, split cells = line.split(',"') sublist = [] for cell in cells: cell = cell.replace('"', '') sublist.append(cell) data.append(sublist) # Finally, convert this list of rows into a dataframe df = pd.DataFrame(data, columns = ['No.', 'Time', 'Source', 'Destination', 'Protocol', 'Length', 'Info']) # Finally, get No. Source and Destination into a new dataframe and print df2 = df[['No.', 'Source', 'Destination']] print(df2.head())

Related Samples

At ProgrammingHomeworkHelp.com, we offer an extensive collection of Python assignment samples to assist students in mastering their coursework. Our samples cover a wide range of topics, including data analysis, web development, machine learning, and more. Each sample is meticulously crafted by our experts to ensure clarity and accuracy, providing a valuable resource for students seeking guidance. Whether you're struggling with a specific concept or need help with an entire project, our Python assignment samples are designed to support your academic success.