Python Forum
Write specific rows from pandas dataframe to csv file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write specific rows from pandas dataframe to csv file
#4
(Oct-18-2018, 08:25 PM)pradeepkumarbe Wrote: Yes I agree UUID will solve my problem, but my output should be like below here how can we avoid Iteration?

Territory   NoOfCustomers    UniqueId 
D00060       10              0001ABSDFG79
D00060       10              0001ABKJKJ90
D00060       10              0001ABVVVV92
D00060       10              0001ABJHJJ93
D00060       10              0001ABCCVV95

You don't avoid iteration - you don't write it explicitly. pandas does it for you under the hood.

uuid.uuid<n>() yields one value on each call - yet you can assign its output to a DataFrame column. You can use any function on the right side of the assignment - or you may have a list/tuple, in the latter case the only limitation being that the length of the list macthes number of rows in your DataFrame
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
RE: Write specific rows from pandas dataframe to csv file - by volcano63 - Oct-18-2018, 09:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Add NER output to pandas dataframe dg3000 0 146 Apr-22-2024, 08:14 PM
Last Post: dg3000
  HTML Decoder pandas dataframe column mbrown009 3 1,064 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  Errors if an xlsx file has blank rows in the beginning…. tester_V 1 848 Aug-28-2023, 06:22 PM
Last Post: deanhystad
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 1,136 Jan-06-2023, 10:53 PM
Last Post: haihal
Smile How to further boost the data read write speed using pandas tjk9501 1 1,276 Nov-14-2022, 01:46 PM
Last Post: jefsummers
  Split excel file and write output at specific row and set sheet position DSCA 0 2,008 May-12-2022, 07:29 PM
Last Post: DSCA
  export dataframe to file.txt dramauh 5 1,950 Apr-21-2022, 01:23 AM
Last Post: sarahroxon7
  Pandas Dataframe Filtering based on rows mvdlm 0 1,453 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 2,339 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,279 Jan-30-2022, 10:21 AM
Last Post: anto5

Forum Jump:

User Panel Messages

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