<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Getting started
Python basiscs
Loading data
Plotting data
Python basics
For a data scientist learning some basic data structures available in python is very important for efficient usage of the tools available in the python ecosystem. 
Variables
Variables can be defined using any alphanumeric string which starts with an alphabet or "_". It can include "_" in it.
Step1:  Lists
A list is a data structure which can hold a list of items of different types. Think of a shopping list. Items in the list can be accessed using zero based index. You will use these when you want to add more data and access the data based on the position in index.
Step2:  Sets
Like list but only store unique items which are hashable (think basic data types like string, ints and not lists, will explain later). Super useful for checking if an item is already in the list. Items are not indexed. So items can only be added or removed. You will use these when you want to keep track of unique items e.g. feature names in the data.
Step3:  Dictionaries
Like sets but can also map values to each unique item. Essentially, it stores key-value pairs which are useful for fast lookup of items. Think of telephone directory or shopping catalogue. Keys should be of same time as items in sets, but values can be anything. You will use these when you want to keep unique items and their related values e.g. words in the data and the number of times they occur.
Step4:  Functions
Using a function is handy in cases when you need to repeat something over an over again. A function can take arguments and return some variables. 
E.g. if you want to fetch tweets using different queries then you can define a function which takes the query and gives you as output the tweets on that query. You can then just call the function with different queries rather than rewriting the whole code for getting the queries.
Step5:  Loading Data
Step6:  Pandas
Pandas is a wonderful library for working with tabular data in python. It can read csv files easily and represents them as dataframes. Think of it like excel but faster and without a GUI.
Step7:  Filtering data 
Filtering parts of the data in pandas is really easy. 
If you want to filter data for editing it then you need to make a copy of the filtered data.
Step8:  Titanic data
```
VARIABLE DESCRIPTIONS
Step9:  Plotting data
Great for visual inspection.
Matplotlib and Seaborn
Matplotlib is a low level python library which gives you complete control over your plots. 
Seaborn is a library made on top of matplotlib and which adds functionality to create certain types of plots easily. Works great with pandas.
Step10:  Question
<ASSISTANT_TASK:>
Python Code:
a = 10
b = 20
c = "Hello"
print a, b, c
Explanation: Getting started
Python basiscs
Loading data
Plotting data
Python basics
For a data scientist learning some basic data structures available in python is very important for efficient usage of the tools available in the python ecosystem. 
Variables
Variables can be defined using any alphanumeric string which starts with an alphabet or "_". It can include "_" in it.
End of explanation
list_items = ["milk", "cereal", "banana", 22.5, [1,2,3]]  ## A list can contain another list and items of different types
print list_items
print "3rd item in the list: ", list_items[2] # Zero based index starts from 0 so 3rd item will have index 2
Explanation: Lists
A list is a data structure which can hold a list of items of different types. Think of a shopping list. Items in the list can be accessed using zero based index. You will use these when you want to add more data and access the data based on the position in index.
End of explanation
set_items = set([1,2,3, 1])
print set_items
print "Is 1 in set_items: ", 1 in set_items
print "Is 10 in set_items: ", 10 in set_items
Explanation: Sets
Like list but only store unique items which are hashable (think basic data types like string, ints and not lists, will explain later). Super useful for checking if an item is already in the list. Items are not indexed. So items can only be added or removed. You will use these when you want to keep track of unique items e.g. feature names in the data.
End of explanation
item_details = {
    "milk": {
        "brand": "Amul",
        "quantity": 2.5,
        "cost": 10
    },
    "chocolate": {
        "brand": "Cadbury",
        "quantity": 1,
        "cost": 5
    },
}
print item_details
print "What are is the brand of milk: ", item_details["milk"]["brand"]
print "What are is the cost of chocolate: ", item_details["chocolate"]["cost"]
Explanation: Dictionaries
Like sets but can also map values to each unique item. Essentially, it stores key-value pairs which are useful for fast lookup of items. Think of telephone directory or shopping catalogue. Keys should be of same time as items in sets, but values can be anything. You will use these when you want to keep unique items and their related values e.g. words in the data and the number of times they occur.
End of explanation
def get_items_from_file(filename):
    data = []
    with open(filename) as fp:
        for line in fp:
            line = line.strip().split(" ")
            data.append(line)
    return data
print "Data in file data/temp1.txt"
print get_items_from_file("../data/temp1.txt")
print "Data in file data/temp2.txt"
print get_items_from_file("../data/temp2.txt")
Explanation: Functions
Using a function is handy in cases when you need to repeat something over an over again. A function can take arguments and return some variables. 
E.g. if you want to fetch tweets using different queries then you can define a function which takes the query and gives you as output the tweets on that query. You can then just call the function with different queries rather than rewriting the whole code for getting the queries.
End of explanation
from scipy.io import arff
data, meta = arff.loadarff("../data/iris.arff")
data.shape, meta
data[0]
Explanation: Loading Data
End of explanation
import pandas as pd
df_iris = pd.DataFrame(data, columns=meta.names())
df_iris.head()
print "The shape of iris data is: ", df_iris.shape
print "Show how many instances are of each class: "
df_iris["class"].value_counts()
df_iris["sepallength"].hist(bins=10)
Explanation: Pandas
Pandas is a wonderful library for working with tabular data in python. It can read csv files easily and represents them as dataframes. Think of it like excel but faster and without a GUI.
End of explanation
print "Show data containing with petalwidth > 2.0"
df_iris[df_iris["petalwidth"] > 2.0]
Explanation: Filtering data 
Filtering parts of the data in pandas is really easy. 
If you want to filter data for editing it then you need to make a copy of the filtered data.
End of explanation
df = pd.read_csv("../data/titanic.csv")
df.shape
df.head()
Explanation: Titanic data
```
VARIABLE DESCRIPTIONS:
survival        Survival
                (0 = No; 1 = Yes)
pclass          Passenger Class
                (1 = 1st; 2 = 2nd; 3 = 3rd)
name            Name
sex             Sex
age             Age
sibsp           Number of Siblings/Spouses Aboard
parch           Number of Parents/Children Aboard
ticket          Ticket Number
fare            Passenger Fare
cabin           Cabin
embarked        Port of Embarkation
                (C = Cherbourg; Q = Queenstown; S = Southampton)
SPECIAL NOTES:
Pclass is a proxy for socio-economic status (SES)
 1st ~ Upper; 2nd ~ Middle; 3rd ~ Lower
Age is in Years; Fractional if Age less than One (1)
 If the Age is Estimated, it is in the form xx.5
With respect to the family relation variables (i.e. sibsp and parch)
some relations were ignored.  The following are the definitions used
for sibsp and parch.
Sibling:  Brother, Sister, Stepbrother, or Stepsister of Passenger Aboard Titanic
Spouse:   Husband or Wife of Passenger Aboard Titanic (Mistresses and Fiances Ignored)
Parent:   Mother or Father of Passenger Aboard Titanic
Child:    Son, Daughter, Stepson, or Stepdaughter of Passenger Aboard Titanic
Other family relatives excluded from this study include cousins,
nephews/nieces, aunts/uncles, and in-laws.  Some children travelled
only with a nanny, therefore parch=0 for them.  As well, some
travelled with very close friends or neighbors in a village, however,
the definitions do not support such relations.
```
End of explanation
# We need the line below to show plots directly in the notebook.
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("ticks")
sns.set_context("paper")
colors = {
    "Iris-setosa": "red",
    "Iris-versicolor": "green",
    "Iris-virginica": "blue",
}
plt.scatter(df_iris.petallength, df_iris.petalwidth, c=map(lambda x: colors[x], df_iris["class"]))
plt.xlabel("petallength")
plt.ylabel("petalwidth")
sns.lmplot(x="petallength", y="petalwidth", hue="class", data=df_iris, fit_reg=False)
sns.pairplot(df_iris, hue="class")
sns.countplot(x="sex", data=df)
sns.countplot(x="class", data=df)
sns.countplot(x="embark_town", data=df)
sns.countplot(x="alive", data=df)
sns.countplot(x="alone", data=df)
sns.lmplot(x="age", y="survived", hue="sex", data=df, fit_reg=True, logistic=True)
sns.barplot(x="sex", y="survived", hue="embark_town", data=df)
sns.barplot(x="sex", y="survived", hue="class", data=df)
sns.barplot(x="sex", y="survived", hue=pd.cut(df.age, bins=[0,18,30,100]), data=df)
sns.barplot(x="sex", y="survived", hue="alone", data=df)
sns.barplot(x="sex", y="survived", hue=pd.cut(df.sibsp, bins=[0,1,2,3,10]), data=df)
sns.barplot(x="sex", y="survived", hue=pd.cut(df.parch, bins=[0,1,2,3,10]), data=df)
sns.barplot(x="sex", y="age", hue=pd.cut(df.parch, bins=[0,1,2,3,10]), data=df)
sns.barplot(x="sex", y="age", hue=pd.cut(df.sibsp, bins=[0,1,2,3,10]), data=df)
sns.barplot(x="sex", y="age", hue="embark_town", data=df)
sns.barplot(x="sex", y="age", hue="class", data=df)
Explanation: Plotting data
Great for visual inspection.
Matplotlib and Seaborn
Matplotlib is a low level python library which gives you complete control over your plots. 
Seaborn is a library made on top of matplotlib and which adds functionality to create certain types of plots easily. Works great with pandas.
End of explanation
sns.barplot(x="class", y="petalwidth", hue=pd.cut(df_iris.petallength, bins=[0, 2.5, 4.5, 6.5, 10]), data=df_iris)
Explanation: Question: Draw the plot of mean petalwidth of the various categories of Iris-classes. It should show the mean petalwidth for each petallengths in buckets [0, 2.5, 4.5, 6.5, 10]
ANSWER BELOW
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
End of explanation
<END_TASK>