<jupyter_start><jupyter_text>02 - Filtering and Sorting Data  Step 1. Import the necessary libraries<jupyter_code>import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset `Euro_2012_stats_TEAM` from folder `data`. Assign it to a variable called euro12<jupyter_code>euro12 = pd.read_csv("data/Euro_2012_stats_TEAM.csv")<jupyter_output><empty_output><jupyter_text>Step 3. Use `.info()` to get a glimpse of the dataframe<jupyter_code>euro12.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 16 entries, 0 to 15
Data columns (total 35 columns):
 #   Column                      Non-Null Count  Dtype  
---  ------                      --------------  -----  
 0   Team                        16 non-null     object 
 1   Goals                       16 non-null     int64  
 2   Shots on target             16 non-null     int64  
 3   Shots off target            16 non-null     int64  
 4   Shooting Accuracy           16 non-null     object 
 5   % Goals-to-shots            16 non-null     object 
 6   Total shots (inc. Blocked)  16 non-null     int64  
 7   Hit Woodwork                16 non-null     int64  
 8   Penalty goals               16 non-null     int64  
 9   Penalties not scored        16 non-null     int64  
 10  Headed goals                16 non-null     int64  
 11  Passes                      16 non-null     int64  
 12  Passes completed            16 non-null     int64  
 13  Passing Accuracy            16 non-nu[...]<jupyter_text>Step 4. Select only the `Goal` column<jupyter_code>#1
euro12['Goals']
#2
euro12.Goals
#3
euro12.iloc[:, 1]<jupyter_output><empty_output><jupyter_text>Step 5. How many teams participated in the Euro2012?<jupyter_code>#1
euro12['Team'].nunique()
#2
len(euro12['Team'].unique())<jupyter_output><empty_output><jupyter_text>Step 6. What is the number of columns in the dataset?<jupyter_code>#1
euro12.shape[1]
#2
len(euro12.columns)<jupyter_output><empty_output><jupyter_text>Step 7. View only the columns Team, Yellow Cards and Red Cards and assign them to a dataframe called `discipline`<jupyter_code>discipline = euro12[["Team", "Yellow Cards", "Red Cards"]]<jupyter_output><empty_output><jupyter_text>Step 8. Sort the teams by Red Cards, then to Yellow Cards<jupyter_code>discipline.sort_values(["Red Cards", "Yellow Cards"], ascending = [False, False])<jupyter_output><empty_output><jupyter_text>Step 9. Calculate the mean Yellow Cards given per Team<jupyter_code>discipline['Yellow Cards'].mean()<jupyter_output><empty_output><jupyter_text>Step 10. Filter teams that scored more than 6 goals<jupyter_code>euro12[euro12['Goals'] > 6]<jupyter_output><empty_output><jupyter_text>Step 11. Select the teams that start with G<jupyter_code>euro12[euro12['Team'].str.startswith('G')]
euro12[euro12['Team'].str[0] == 'G']<jupyter_output><empty_output><jupyter_text>Step 12. Select the first 7 columns<jupyter_code>euro12.iloc[:, :7]<jupyter_output><empty_output><jupyter_text>Step 13. Select all columns except the last 3<jupyter_code>euro12.iloc[:, :-3]<jupyter_output><empty_output><jupyter_text>Step 14. Present only the Shooting Accuracy from England, Italy and Russia<jupyter_code>euro12.loc[(euro12.Team == "England") | (euro12.Team == "Italy") | (euro12.Team == "Russia"), ["Team","Shooting Accuracy"]]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11213563355145746, 'fraction_numerical': 0.049970255800118976, 'mean_word_length': 3.5262449528936743, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 58, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '635661', 'license': 'MIT', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1140, 'n_words': 285, 'path': 'week4_EDA_np_pd_json_apis_regex/pandas_ejer/Euro12_RES.ipynb', 'repo_name': 'paleomau/MGOL_BOOTCAMP', 'size': '3362'}