×
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
When working on OCaml assignments, make use of pattern matching to simplify your code. It provides a clean and efficient way to handle different cases, especially for recursive functions and data structures like lists and trees. This can reduce complexity and improve readability.
News
Universities worldwide are seeing a surge in programming enrollment, as coding becomes an essential skill across disciplines. To meet growing academic pressures, more students are seeking online help for programming assignments and coursework.

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.