Python Forum
Pandas Indexing with duplicates
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas Indexing with duplicates
#3
Hi @scidam,

your function : df.ix[['Street name']] work but only returns the first occurence with the name of the street. As I indicated, my index is the street names and contains many duplicates. For instance, 'WashingtonStreet' would occur 30 times in my database since there are 30 points on that street. I would like to be able to print them all with 1 command.

my data structure would look like this :
Output:
Index FID X Y Bearing E_ID WashingtonStreet 55 6156789 51234456 279.5 '' WashingtonStreet 56 6156413 51234446 279.5 '' WashingtonStreet 77 6156695 51234785 279.5 '' WashingtonStreet 98 6156744 51234748 279.5 '' WashingtonStreet 52 6156784 51234963 279.5 ''

I found my answer. By moving the index (street names) back as a column, the following syntax worked :

print(sub_df[sub_df.AQROUTES_3=='AvenueMermoz'])
Reply


Messages In This Thread
RE: Pandas Indexing with duplicates - by scidam - Mar-05-2019, 11:44 PM
RE: Pandas Indexing with duplicates - by energerecontractuel - Mar-06-2019, 01:48 PM
RE: Pandas Indexing with duplicates - by scidam - Mar-07-2019, 12:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Add group number for duplicates atomxkai 2 1,157 Dec-08-2022, 06:08 AM
Last Post: atomxkai
  Counting Duplicates in large Data Set jmair 3 1,161 Dec-07-2022, 09:42 AM
Last Post: paul18fr
  Convert indexing For Loop from MATLAB (uses numpy and pandas) bentaz 3 4,219 Mar-20-2018, 08:29 PM
Last Post: bentaz
  jupyter pandas remove duplicates help okl 3 7,543 Feb-25-2018, 01:11 PM
Last Post: glidecode

Forum Jump:

User Panel Messages

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