Question

1. In Python, Create a CSV file that has 10 items with topic headers that are...

1. In Python, Create a CSV file that has 10 items with topic headers that are separated by commas.

Example: a,b,c,d,total

1,2,3,4,number

2. Use the Python pandas function to read the CSV file into a Dataframe. Provide a screenshot or the actual output.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the answer:


Explanation:

import pandas as pd

ProjectPath = os.getcwd()

filename = "TestFile.csv"

MyPath = ProjectPath + '\\' + filename

data_df = pd.read_csv(MyPath)

print(data_df)

Python Output

>>>

RESTART: E:\CDAC_31_12_2017_Backup\CheggIndia_Anshu_Office\PythonCode\CheggPython.py

<_csv.reader object at 0x0605A630>

>>>

RESTART: E:\CDAC_31_12_2017_Backup\CheggIndia_Anshu_Office\PythonCode\CheggPython.py

  a  b  c  d  total

0  1  2  3  4  number

1  u  v  w  x letters

2 10 20 30 40  prices

3  a  b  c  d  total

4  1  2  3  4  number

5  u  v  w  x letters

6 10 20 30 40  prices

7  u  v  w  x letters

8 10 20 30 40  prices

>>>

Add a comment
Know the answer?
Add Answer to:
1. In Python, Create a CSV file that has 10 items with topic headers that are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Any Language write a function to loop through a csv file (10 rows no headers)...

    In Any Language write a function to loop through a csv file (10 rows no headers) and pull out the data from the 3rd column (string). Create one string with those values separated by commas in arranged in alphabetical order by the first letter (example: “Amazon, Aaron, Base, …..”, Amazon and Aaron do not need to be reversed). It can be assumed the csv file is already read into a variable. Please provide comments.

  • PYTHON PROGRAMMING LANGUAGE Task 5 Open a csv file for writing create 3 rows that store...

    PYTHON PROGRAMMING LANGUAGE Task 5 Open a csv file for writing create 3 rows that store username, first name, last name and age data (four columns) write the data to the csv file under the correct column Task 6 Open the file in task 5) and read its contents Output the content in a tabular format of columns and values

  • Python Assignment In this assignment, you will use Pandas library to perform analysis on the dataset stored in the following csv file: breast-cancer-wisconsin.csv. Please write script(s) to do the fol...

    Python Assignment In this assignment, you will use Pandas library to perform analysis on the dataset stored in the following csv file: breast-cancer-wisconsin.csv. Please write script(s) to do the following: 1. Read the csv file and covert the dataset into a DataFrame object. 2. Persist the dataset into a SQL table and a JASON file. • Write the content of the DataFrame object into an SQLite database table. This will convert the dataset into a SQL table format. You can...

  • Write a class named SatData that reads a JSON file containing data on 2010 SAT results...

    Write a class named SatData that reads a JSON file containing data on 2010 SAT results for New York City and writes the data to a text file in CSV (comma-separated values) format. It just needs to read a local JSON file - it doesn't need to access the internet. Specifically, your class should have an init method that reads the file, and it should have a method named save_as_csv that takes as a parameter a list of DBNs (district...

  • Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create...

    Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create a completed program that prompts the user for the name of a data file, and reads the contents of that data file, then creates variables in a form suitable for computing the answer to some questions. The format should be in the same manner as the attached .py file. All subsequent assignment details (.py and .csv files) can be found at this...

  • Pandas DataFrame in Python : I have csv file which has date column with object data...

    Pandas DataFrame in Python : I have csv file which has date column with object data type which ranges from 1908 to 2018: (Original) Date                 (My result) Date                  (I Need) Date                       17-Sep-08                                  2008-09-17                 1908-09-17 7-Sep-09                                    2009-09-07                  1909-09-07 .    (more years)                         .   (more years)               .     .                                                 .                                      . 8-Nov-07                                       2007-11-07                 2007-11-07 23-Sep-08                                     2008-09-23                 2008-09-23 29-Dec-18                                     2018-12-29                 2018-12-29 When I am converting it to datetime64[ns] or/and adding column as year after extracting just year values from date...

  • According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses...

    According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A company has text data that is not...

  • In Python!! 1. Correcting string errors It's easy to make errors when you're trying to type...

    In Python!! 1. Correcting string errors It's easy to make errors when you're trying to type strings quickly. Don't forget to use quotes! Without quotes, you'll get a name error. owner = DataCamp Use the same type of quotation mark. If you start with a single quote, and end with a double quote, you'll get a syntax error. fur_color = "blonde' Someone at the police station made an error when filling out the final lines of Bayes' Missing Puppy Report....

  • Python with Pandas dataframe I have a csv file that contains a large number of columns...

    Python with Pandas dataframe I have a csv file that contains a large number of columns and rows. I need to write a script that concatenates some elements of the first row with some elements of the 2 row. Something like # if data[1][0] starts with ch then concatenate the element right below it. I have attached a picture of just a sample of my data. The booleans have to stay on there as is. But I must drop the...

  • PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text...

    PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text where each line in the file represents one record of information, and each piece of info in the record is separated by a single comma. Luckily the values won't ever contain commas themselves for this project. But they might start or end with non visible characters (e.g. space, tab). Thus, you must remove the leading and trailing spaces when you store the data in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT