Python Forum
Pandas Indexing with duplicates
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas Indexing with duplicates
#4
Look at the following example

import pandas as pd
df = pd.DataFrame({'streets':['street1'] * 3+['street2'] * 4, 'unit': range(7)}).set_index('streets')
I can select all streets by name, e.g. (street1):

df.ix[['street1']]
Output:
unit streets street1 0 street1 1 street1 2
Your solution is good as well.
Reply


Messages In This Thread
RE: Pandas Indexing with duplicates - by scidam - Mar-05-2019, 11:44 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,094 Dec-08-2022, 06:08 AM
Last Post: atomxkai
  Counting Duplicates in large Data Set jmair 3 1,092 Dec-07-2022, 09:42 AM
Last Post: paul18fr
  Convert indexing For Loop from MATLAB (uses numpy and pandas) bentaz 3 4,140 Mar-20-2018, 08:29 PM
Last Post: bentaz
  jupyter pandas remove duplicates help okl 3 7,471 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