<jupyter_start><jupyter_text>Import Pandas<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>Read in the dataset<jupyter_code>data = pd.read_csv('data-zillow.csv')
data.head()<jupyter_output><empty_output><jupyter_text>Get Mean price for every State<jupyter_code>grouped_data = data[['State', 'Price']].groupby('State').mean()
grouped_data.head()<jupyter_output><empty_output><jupyter_text>Split the data into groups<jupyter_code>grouped_data = data[['State', 'Price']].groupby('State')
list(grouped_data)<jupyter_output><empty_output><jupyter_text>Apply a function on each group and combine the results<jupyter_code>grouped_data.mean().head()<jupyter_output><empty_output><jupyter_text>Get Descriptive statistics by Groups(States)<jupyter_code>grouped_data.describe()<jupyter_output><empty_output><jupyter_text>Group by data on State and Region<jupyter_code>grouped_data = data[['State',
                     'RegionName', 
                     'Price']].groupby(['State','RegionName']).mean()
grouped_data.head()<jupyter_output><empty_output><jupyter_text>Get the number of records per State<jupyter_code>grouped_data = data.groupby(['State']).size()
grouped_data<jupyter_output><empty_output><jupyter_text>Group by Columns<jupyter_code>grouped_data = data.groupby(data.dtypes, axis=1)
list(grouped_data)<jupyter_output><empty_output><jupyter_text>Iterate over Groups<jupyter_code>for state, grouped_data in data.groupby('State'):
    print(state, '\n', grouped_data)<jupyter_output>AK 
              Date  RegionID    RegionName State      Metro  \
57     2017-05-31     23482     Anchorage    AK  Anchorage   
842    2017-05-31     38465     Fairbanks    AK  Fairbanks   
1793   2017-05-31     36906        Palmer    AK  Anchorage   
1830   2017-05-31     29910    North Pole    AK  Fairbanks   
1974   2017-05-31      5365        Juneau    AK     Juneau   
3756   2017-05-31     52742         Kenai    AK        NaN   
3869   2017-05-31     39281        Kodiak    AK        NaN   
4450   2017-05-31    102611       Tanaina    AK  Anchorage   
5229   2017-05-31     32296     Ketchikan    AK  Ketchikan   
5996   2017-05-31    395445         Lakes    AK  Anchorage   
9622   2017-05-31     54367        Seward    AK        NaN   
10162  2017-05-31     28124  Anchor Point    AK        NaN   

                     County  SizeRank   Price  
57                Anchorage        57  293900  
842    Fairbanks North Star       842  221000  
1793      <NAME>      1793  24780[...]
{'fraction_non_alphanumeric': 0.09381237524950099, 'fraction_numerical': 0.09540918163672654, 'mean_word_length': 3.0550161812297736, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '340044', 'license': 'MIT', 'n_tokens_mistral': 1044, 'n_tokens_neox': 864, 'n_words': 166, 'path': 'Chapter03/Using groupby method.ipynb', 'repo_name': 'dragonyy/Mastering-Exploratory-Analysis-with-pandas', 'size': '2516'}