<jupyter_start><jupyter_text>InstructionsYou're going to practice working in Pandas. You'll walk through instantiating a `DataFrame`, reading data into it, looking at and examining that data, and then playing with it. A dataset on the [quality of red wines](https://archive.ics.uci.edu/ml/datasets/wine+quality) is used for this purpose.It is lokated in the `data` folder within this directory. It's called `winequality-red.csv`. Typically, we use Jupyter notebooks like this for a very specific set of things - presentations and EDA. Today, as we'll be playing around with `Pandas`, much of what we'll be doing is considered EDA. Therefore, by using a notebook, we'll get a tighter feedback loop with our work than we would trying to write a script. But, in general, **we do not use Jupyter notebooks for development**. Below, we've put a set of questions and then a cell for you to work on answers. However, feel free to add additional cells if you'd like. Often it will make sense to use more than one cell for your answers.  Assignment Questions  Part 1 - The Basics of DataFramesLet's start off by following the general workflow that we use when moving data into a DataFrame:     * Importing Pandas    * Reading data into the DataFrame    * Getting a general sense of the dataSo, in terms of what you should do for this part...1. Import pandas2. Read the wine data into a DataFrame. 3. Use the `attributes` and `methods` available on DataFrames to answer the following questions:     * How many rows and columns are in the DataFrame?    * What data type is in each column?    * Are all of the variables continuous, or are any categorical?    * How many non-null values are in each column?    * What are the min, mean, max, median for all numeric columns?<jupyter_code>import pandas as pd

df = pd.read_csv("data/winequality-red.csv", delimiter= ";")
df.head()
df.shape
df.info()
df.describe()
df<jupyter_output><empty_output><jupyter_text>Part 2 - Practice with Grabbing DataLet's now get some practice with grabbing certain parts of the data. If you'd like some extra practice, try answering each of the questions in more than one way (because remember, we can often grab our data in a couple of different ways). 1. Grab the first 10 rows of the `chlorides` column. 2. Grab the last 10 rows of the `chlorides` column. 3. Grab indices 264-282 of the `chlorides` **and** `density` columns. 4. Grab all rows where the `chlorides` value is less than 0.10. 5. Now grab all the rows where the `chlorides` value is greater than the column's mean (try **not** to use a hard-coded value for the mean, but instead a method).6. Grab all those rows where the `pH` is greater than 3.0 and less than 3.5. 7. Further filter the results from 6 to grab only those rows that have a `residual sugar` less than 2.0.<jupyter_code>df.loc[0:9,["chlorides"]]
df["chlorides"].tail(10)
df.loc[264:282,["chlorides", "density"]]
df[df["chlorides"] < 0.1]
df[df["chlorides"] > df["chlorides"].mean()]
df[(df["pH"] > 3.0) & (df["pH"] < 3.5)]
df[(df["pH"] > 3.0) & (df["pH"] < 3.5) & (df["residual sugar"] < 2.0)]<jupyter_output><empty_output><jupyter_text>Part 3 - More PracticeLet's move on to some more complicated things. Use your knowledge of `groupby`s, `sorting` to answer the following. 1. Get the average amount of `chlorides` for each `quality` value. 2. For observations with a `pH` greater than 3.0 and less than 4.0, find the average `alcohol` value by `pH`. 3. For observations with an `alcohol` value between 9.25 and 9.5, find the highest amount of `residual sugar`. 4. Create a new column, called `total_acidity`, that is the sum of `fixed acidity` and `volatile acidity`. 5. Find the average `total_acidity` for each of the `quality` values. 6. Find the top 5 `density` values. 7. Find the 10 lowest `sulphates` values.<jupyter_code>df.rename(columns={'fixed acidity': 'fixed_acidity'}, inplace=True)
df.rename(columns={'volatile acidity': 'volatile_acidity'}, inplace=True)
df.groupby(["quality"]).mean()['chlorides']
a = df[(df["pH"] > 3.0) & (df["pH"] < 4.0)]
a.mean()["alcohol"]
a = df[(df["alcohol"] > 9.25) & (df["alcohol"] < 9.5)]
a.groupby(["alcohol"]).max()["residual sugar"]
df.eval('total_acidity = fixed_acidity + volatile_acidity', inplace = True) 
df.columns
a = df.groupby("total_acidity")
a = a.mean()['quality']
a
df.sort_values(["density"]).head(5)
df.sort_values(["sulphates"], ascending=False).head(10)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1135341726618705, 'fraction_numerical': 0.01933453237410072, 'mean_word_length': 4.653113087674714, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 18, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '492340', 'license': 'MIT', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1331, 'n_words': 607, 'path': '02_pandas_practice_1.ipynb', 'repo_name': 'Jaoaud/Numpy_Pandas', 'size': '4448'}