In [14]:
#initial list
initial_list = [0,1,2,3,4,5,6,7,8,9]
#Save the 4th first elements of the list below to new_list (tip: use [something:something])
new_list =
#Append value "8" to new_list.
seomthing = something + something
#print result
In [17]:
#initial list
initial_list = [6, 2, 8, 5, 6, 3, 9, 9, 8, 6, 7, 0, 7, 7, 0, 6, 4, 6, 6, 4, 3, 6, 0,
1, 3, 6, 1, 9, 8, 9, 0, 6, 2, 1, 4, 4, 1, 7, 5, 3, 2, 2, 2, 0, 5, 8,
2, 0, 8, 3, 7, 0, 9, 9, 6, 3, 8, 8, 7, 7, 2, 2, 6, 5, 5, 0, 8, 7, 6,
9, 8, 0, 6, 2, 2, 8, 4, 6, 0, 3, 4, 8, 1, 4, 3, 9, 7, 9, 7, 0, 4, 7,
1, 7, 9, 8, 8, 0, 7, 7]
#find unique words (tip: convert the list to a set)
initial_set = set(something)
#sort the result (tip: convert to a list before)
new_list = l
new_list.something()
print(new_list)
#print it
In [20]:
#initial_dict
this_is_a_dict = {"Javier": 63434234234, "Friend1": 4234423243, "Friend2": 424233345}
#change the phone number of friend2 (tip: use this_is_a_dict["Friend2"] = ...)
#add friend3
In [ ]:
initial_list = ["aArOn","bArR","AmAdDa","RIk"]
#create an empty list called new_list
#for each_element in initial_list:
# check the first letter
# if == "A" make the element uppercase and append it to "new_list"
In [2]:
#make csv
with open("./data/example_python_year.csv",fill) as f:
f.write("10\t\2000\n")
f.write("20\t\2000\n")
f.write("15\t\2000\n")
f.write("50\t\2000\n")
f.write("8\t\2000\n")
f.write("30\t\2000\n")
f.write("40\t\2000\n")
f.write("3\t\1990\n")
f.write("4\t\1990\n")
f.write("6\t\1990\n")
f.write("1\t\1990\n")
f.write("10\t\1990\n")
f.write("20\t\1990\n")
f.write("5\t\1990\n")
In [ ]:
import numpy as np
def keepyear(list_lines):
times_1990 = []
times_2000 = []
for each_element in list_lines:
times,year = each_element.split(fill)
if year.fill == fill:
times_1990.append(times)
else:
times_2000.append(times)
return times_1990,times_2000
def plot(x,y):
plt.bar(x,y)
plt.show()
#read data
with open("./data/example_python_year.csv",fill) as f:
list_lines = f.fill
#get lists and means
times_1990,times_2000 = fill
mean_1990 = np.mean(fill)
mean_2000 = np.mean(fill)
#plot
fill
In [8]:
#Make the two last steps with pandas
import pandas as pd
import pylab as plt
df = pd.read_csv("./data/example_python_year.csv",sep="\t",header=None,index_col=None)
df.columns = ["Times","Year"]
meanData = df.groupby("Year").mean().reset_index()
meanData.plot(x = "Year", y = "Times", kind="bar")
plt.show()
In [9]:
from scipy.stats import mannwhitneyu
print(mannwhitneyu(times_1990,times_2000))