0

I feel it's simple task and I am not using right term probably

df = pd.DataFrame({'Name': ['Honda', 'Toyota', 'Toyota','BMW','Hyundai', 'BMW']
                , 'Price': ['2000', '3000', '2000','4000','6000', '8000']
                , 'Year': ['2001', '2002', '2002','2003','2004', '2005']})

    Name    Price   Year
0   Honda   2000    2001
1   Toyota  3000    2002
2   Toyota  2000    2002
3   BMW     4000    2003
4   Hyundai 6000    2004
5   BMW     8000    2005

I want to perform operations like group by, drop , count and so on not on column or row but based on specific element For example drop all Honda data elements - which should drop Honda and its associated elements from all columns and each row

I am finding examples which does specific rows with iloc and so on but since data is disperse all honda elements won't be within index.

Also data on which I want to perform operation is timeseries so group by for particular element changes dataframe

oneday
  • 629
  • 1
  • 9
  • 32
  • please clarify your question with details on what exactly you want to do along with an expected dataframe. Multiple questions are discouraged in SO and should be avoided – anky Sep 04 '21 at 18:40
  • 2
    Dont really understand your requirement, but dropping `Honda` is as simple as `df[df["Name"]!="Honda"]`. – Henry Yik Sep 04 '21 at 18:40
  • @HenryYik - That's what I was looking for - I knew it was a noob question but my google with choice of words wasn't just yielding results - thanks a lot - if u can put it in answer I can go ahead and accept it – oneday Sep 04 '21 at 18:50
  • @anky - my question was primarily around selection of element and performing operations on top of it – oneday Sep 04 '21 at 18:52
  • 1
    It's fine. You can get a detailed explanation in [How do I select rows from a DataFrame based on column values?](https://stackoverflow.com/a/17071908/9284423). – Henry Yik Sep 04 '21 at 18:52
  • Yes it does - that was all I was looking for - and I can i see why its so much upvoted question and answer :) – oneday Sep 04 '21 at 19:15

0 Answers0