<jupyter_start><jupyter_text>DataFrame exploration  checking the data type of the variable df<jupyter_code>type(df)<jupyter_output><empty_output><jupyter_text>getting the first 3 rows<jupyter_code>df.head(3)<jupyter_output><empty_output><jupyter_text>getting the last 2 rows<jupyter_code>df.tail(2)<jupyter_output><empty_output><jupyter_text>getting a random sample of 5 rows<jupyter_code>df.sample(5)<jupyter_output><empty_output><jupyter_text>getting the number of rows and columns<jupyter_code>df.shape<jupyter_output><empty_output><jupyter_text>getting the columns (labels)<jupyter_code>df.columns<jupyter_output><empty_output><jupyter_text>getting the index (row labels)<jupyter_code>df.index<jupyter_output><empty_output><jupyter_text>shows the statistics of the numeric variables<jupyter_code>df.describe()

# same as:
# df.select_dtypes(include='number').describe()<jupyter_output><empty_output><jupyter_text>***EXERCISE 3.1***Get a DataFrame with just `count` and `mean` (first 2 rows) of the numeric columns<jupyter_code># insert solution here<jupyter_output><empty_output><jupyter_text>shows the statistics of the non-numeric variables<jupyter_code>df.select_dtypes(exclude='number').describe()<jupyter_output><empty_output><jupyter_text>showing the data type of each column (object, in this case, means string)<jupyter_code>df.dtypes<jupyter_output><empty_output><jupyter_text>Series exploration  selecting a single column<jupyter_code>wine_variety = df['variety']<jupyter_output><empty_output><jupyter_text>checking the data type of the variable wine_country<jupyter_code>type(wine_variety)<jupyter_output><empty_output><jupyter_text>getting unique values<jupyter_code>wine_variety.unique()<jupyter_output><empty_output><jupyter_text>getting counts for all unique values**TIP** if, like me, you have trouble remembering if it's "value_count", "count_values" etc.. remember, at the end of the day it is the "value" that "counts".. so it's "value_counts"<jupyter_code>wine_variety.value_counts()<jupyter_output><empty_output><jupyter_text>getting percentage frequency of all unique values<jupyter_code>wine_variety.value_counts(normalize=True)<jupyter_output><empty_output><jupyter_text>***EXERCISE 3.2***Show the 6 least common countries (in absolute value) and the 3 most common wine varieties (in percentage)<jupyter_code># insert code for 6 least common countries
# insert code for 3 most common varieties<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1036734693877551, 'fraction_numerical': 0.006122448979591836, 'mean_word_length': 11.441624365482234, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, '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': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '201085', 'license': 'MIT', 'n_tokens_mistral': 881, 'n_tokens_neox': 836, 'n_words': 168, 'path': '03_exploring_data.ipynb', 'repo_name': 'gabrielecalvo/pandas_tutorial', 'size': '2450'}