Python Forum
Question from beginners: how to combine 2 columns
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question from beginners: how to combine 2 columns
#2
There is no reason to use Pandas on a simple task like this. You can just read the csv file normally.


with open('chicago.csv', 'r') as fp:
    for rec in fp:
        split_rec=rec.strip().split(",")
        ## you now have a list of columns and can use a 
        ## dictionary to count the 2 combined columns
        print(split_rec)

        ## ****** I am not going to do your homework for you ***** 
Reply


Messages In This Thread
RE: Question from beginners: how to combine 2 columns - by woooee - May-12-2018, 04:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PyTorch for beginners OmegaRed94 1 1,107 Jun-09-2022, 09:20 PM
Last Post: Larz60+
  pandas.to_datetime: Combine data from 2 columns ju21878436312 1 2,464 Feb-20-2021, 08:25 PM
Last Post: perfringo
  Grab columns from multiple files, combine into one jon0852 0 2,040 Feb-12-2019, 02:53 AM
Last Post: jon0852

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020