Python Forum
Pandas usecols question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas usecols question
#1
I am very new to Python (just installed yday) and am workink with Pandas, obviously, also new. I have a large csv file I am trying to read and then send to a MySQL database. The problem is, the file contains some header information and I need to pull in the table inside the data…say, data starting at row 40 (I believe I can handle this with the skiprows property. I also need to grab, say…columns 9-80. I know there’s the usecols property, but I’m only seeing it used where you specify the name of the column. Questions

1) is there any way to specify a range?
2) I haven’t researched this yet, but could you please refer me to what to look up to xfer the data to MySQL please?

Thank you!
Reply
#2
Clearly you are experienced, so will simply refer you -
iloc is the function you want to specify a range
to_sql is the function to write to a SQL database.

Check the docs for those functions.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pandas df inside a df question mbaker_wv 4 1,193 Dec-25-2022, 01:11 AM
Last Post: mbaker_wv
  Simple pandas question mcva 4 2,664 Dec-17-2021, 04:47 PM
Last Post: mcva
  Pandas question new2datasci 0 1,960 Jan-10-2021, 01:29 AM
Last Post: new2datasci
  Pandas merge question smw10c 2 5,746 Jul-02-2020, 06:56 PM
Last Post: hussainmujtaba
  Counting Criteria in Pandas Question Koenig 1 2,180 Sep-30-2019, 05:16 AM
Last Post: perfringo
  Function question using Pandas smw10c 7 7,140 Feb-12-2019, 06:52 PM
Last Post: Nathandsn
  Simple pandas dataframe question popohoma 1 3,556 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  question on pandas datareader kit12_31 3 9,245 Feb-05-2018, 11:55 PM
Last Post: snippsat
  Newbie question on how to use pandas.rolling_mean zydjohn 5 14,283 Dec-09-2017, 08:42 PM
Last Post: j.crater
  Pandas question takaa 3 3,836 Dec-05-2017, 01:03 PM
Last Post: takaa

Forum Jump:

User Panel Messages

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