Question

0 1 2 3 4 Name Sex Age Alex М. 41 Bert М. 42 Carl M 32 Dave M 39 Elly F. 30 Fran F 33 Gwen F 26 Hank 30 Ivan M 53 Jake 32 5 6   Name Alex Bert Carl 1 2 3 4 5 Dave Elly Fran Gwen Hank Ivan 6 8 9 Jake 10 Kate 11 Luke 12 Myra 13 Neil 14 Omar 15 Page 16 Qui

I'm having problems with my pandas data frame. When I print my data frame, it is appearing as one long column, instead of putting the data side by side as in the left image. I'm working with python. How do I fix this so that name, sex, and age appear side by side like in image on left?

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

1 to 18 of 18 entries Filter Age Name Sex 0 M 41 1 42 M M 2 32 39 3 M 4 F 30 5 F 33 6 F 26 import csv with open(data.csv,

import csv
with open('data.csv', 'w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(["", "Name", "Sex","Age"])
    writer.writerow([0, "Alex", "M",41])
    writer.writerow([1, "Bert", "M",42])
    writer.writerow([2, "Carl", "M",32])
    writer.writerow([3, "Dave", "M",39])
    writer.writerow([4, "Elly", "F",30])
    writer.writerow([5, "Fran", "F",33])
    writer.writerow([6, "Gwen", "F",26])
    writer.writerow([7, "Hank", "M",30])
    writer.writerow([8, "Ivan", "M",53])
    writer.writerow([9, "Jake", "M",32])
    writer.writerow([10, "kate", "F",47])
    writer.writerow([11, "Luke", "M",34])
    writer.writerow([12, "Myra", "F",23])
    writer.writerow([13, "Neil", "M",36])
    writer.writerow([14, "Omar", "M",38])
    writer.writerow([15, "Page", "F",31])
    writer.writerow([16, "Quin", "M",29])
    writer.writerow([17, "Ruth", "F",28])
Add a comment
Know the answer?
Add Answer to:
   I'm having problems with my pandas data frame. When I print my data frame, it...
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
  • + Run C Code IMPORTANT: • Run the following code cell to create the input file,...

    + Run C Code IMPORTANT: • Run the following code cell to create the input file, biostats.csv, which you will be using later. 74, In [ ]: N %%file biostats.csv Name, Sex, Age, Alex, M, 41, Bert, M, 42, Dave, M, 39, Elly, F, 30, Fran, F, 33, Jake, M, F, Luke, M, 34, F Myra, M, M, 38, Ruth, F, 28, 22 22 323 47 47, Height, Weight 170 200 167 70 115 143 139 280 98 75, 350...

  • C++ Create an application that searches a file of male and female first names. A link...

    C++ Create an application that searches a file of male and female first names. A link to the file is provided on the class webpage. "FirstNames2015.txt" is a list of the most popular baby names in the United States and was provided by the Social Security Administration. Each line in the file contains a boy's name and a girl's name. The file is space-delimited, meaning that the space character is used to separate the boy name from the girl name....

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