Data Science Crash Course For Beginners Fundamentals And Practices With Python by AI Publishing

Data Science Crash Course For Beginners Fundamentals And Practices With Python by AI Publishing

Author:AI Publishing
Language: eng
Format: mobi, epub
Publisher: AI Publishing


Let us create a new dataframe myframe2 that is the same as myframe except for an extra entry [‘red’,’pencil’,0.8] at index 5.

1. myframe2 = myframe

2. myframe2.loc[5]=[‘red’,’pencil’,0.8]

3. myframe2

Output:

Now, we group myframe2 by color as well as by object.

1. mygroup2 = myframe2[‘price’]. groupby([myframe2[‘color’],myframe2[‘object’]])

2. mygroup2.groups

Output:

{(‘blue’, ‘ball’): Int64Index([0], dtype=’int64’),

(‘red’, ‘paper’): Int64Index([3], dtype=’int64’),

(‘red’, ‘pencil’): Int64Index([2, 5], dtype=’int64’),

(‘white’, ‘mug’): Int64Index([4], dtype=’int64’),

(‘white’, ‘pen’): Int64Index([1], dtype=’int64’)}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.