<jupyter_start><jupyter_text>___ ___  GroupbyThe groupby method allows you to group rows of data together and call aggregate functions<jupyter_code>import pandas as pd
# Create dataframe
data = {'Company':['GOOG','GOOG','MSFT','MSFT','FB','FB'],
       'Person':['Sam','Charlie','Amy','Vanessa','Carl','Sarah'],
       'Sales':[200,120,340,124,243,350]}
df = pd.DataFrame(data)
df<jupyter_output><empty_output><jupyter_text>** Now you can use the .groupby() method to group rows together based off of a column name. For instance let's group based off of Company. This will create a DataFrameGroupBy object:**<jupyter_code>df.groupby('Company')<jupyter_output><empty_output><jupyter_text>You can save this object as a new variable:<jupyter_code>by_comp = df.groupby("Company")<jupyter_output><empty_output><jupyter_text>And then call aggregate methods off the object:<jupyter_code>by_comp.mean()
df.groupby('Company').mean()<jupyter_output><empty_output><jupyter_text>More examples of aggregate methods:<jupyter_code>by_comp.std()
by_comp.min()
by_comp.max()
by_comp.count()
by_comp.describe()
by_comp.describe().transpose()
by_comp.describe().transpose()['GOOG']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14513422818791946, 'fraction_numerical': 0.015100671140939598, 'mean_word_length': 8.620967741935484, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '53443', 'license': 'MIT', 'n_tokens_mistral': 430, 'n_tokens_neox': 408, 'n_words': 86, 'path': 'python-datasci-bootcamp/03-Python-for-Data-Analysis-Pandas/05-Groupby.ipynb', 'repo_name': 'tapiwam/dataSciProjects', 'size': '1192'}