python:first_course_statistics
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| python:first_course_statistics [2016/10/17 07:41] – [ScatterPlot (p. 7)] fberetta | python:first_course_statistics [2017/09/26 08:54] (Version actuelle) – [General instructions] fberetta | ||
|---|---|---|---|
| Ligne 5: | Ligne 5: | ||
| * pandas [[http:// | * pandas [[http:// | ||
| * [[http:// | * [[http:// | ||
| + | |||
| + | |||
| + | Get the data from [[http:// | ||
| + | |||
| Save your scripts in a folder inside the data folder, calling the script folder ' | Save your scripts in a folder inside the data folder, calling the script folder ' | ||
| Ligne 35: | Ligne 39: | ||
| import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
| import pandas as pd | import pandas as pd | ||
| - | gysr1_boxplot = pd.read_csv(' | + | gysr1_boxplot = pd.read_csv(' |
| data_gysr1 = gysr1_boxplot[' | data_gysr1 = gysr1_boxplot[' | ||
| plt.boxplot(data_gysr1) | plt.boxplot(data_gysr1) | ||
| Ligne 55: | Ligne 59: | ||
| import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
| import pandas as pd | import pandas as pd | ||
| - | geysr1_scatterplot = pd.read_csv(' | + | geysr1_scatterplot = pd.read_csv(' |
| geysr1_data_Xax = geysr1_scatterplot[' | geysr1_data_Xax = geysr1_scatterplot[' | ||
| geysr1_data_Yax = geysr1_scatterplot[' | geysr1_data_Yax = geysr1_scatterplot[' | ||
| Ligne 65: | Ligne 69: | ||
| plt.show() | plt.show() | ||
| </ | </ | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | |||
| + | ===== Descriptive statistics (p.9) ===== | ||
| + | |||
| + | Note: try different examples, e.g. the whole population or only those where ' | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | <code python> | ||
| + | import pandas as pd | ||
| + | gysr1 = pd.read_csv(' | ||
| + | gysr1[' | ||
| + | </ | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| ===== Boxplot (p.9) ===== | ===== Boxplot (p.9) ===== | ||
| Ligne 78: | Ligne 102: | ||
| plt.boxplot([gysr1_inf3[' | plt.boxplot([gysr1_inf3[' | ||
| </ | </ | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| ====== International adoption rates (p.13) ====== | ====== International adoption rates (p.13) ====== | ||
| + | ===== Boxplot (p.14) ===== | ||
| + | |||
| + | <code python> | ||
| + | import matplotlib.pyplot as plt | ||
| + | import pandas as pd | ||
| + | adopt_data = pd.read_csv(' | ||
| + | adopt1 = adopt_data[' | ||
| + | plt.boxplot(adopt1) | ||
| + | ax = plt.gca() | ||
| + | ax.set_title(' | ||
| + | ax.set_xlabel(' | ||
| + | ax.set_ylabel(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | |||
| + | ===== Histogram (p.14) ===== | ||
| + | |||
| + | <code python> | ||
| + | import matplotlib.pyplot as plt | ||
| + | import pandas as pd | ||
| + | adopt_data = pd.read_csv(' | ||
| + | adopt1 = adopt_data[' | ||
| + | plt.hist(adopt1) | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | =====Histogram with Log(p.18)===== | ||
| + | don't find the way to do it | ||
| + | <code Python> | ||
| + | import pandas as pd | ||
| + | import matplotlib.pyplot as plt | ||
| + | adopt = pd.DataFrame(pd.read_csv(' | ||
| + | adopt_loghist = adopt[' | ||
| + | # | ||
| + | ax = plt.gca() | ||
| + | ax.hist(adopt_loghist, | ||
| + | plt.gca().set_xscale(" | ||
| + | ax.set_xlabel(' | ||
| + | ax.set_ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | =====Scatterplot (p. 17)===== | ||
| + | <code python> | ||
| + | import matplotlib.pyplot as plt | ||
| + | import pandas as pd | ||
| + | adoption_scatterplot = pd.read_csv(' | ||
| + | adopt_data_Xax = adoption_scatterplot[' | ||
| + | adopt_data_Yax = adoption_scatterplot[' | ||
| + | plt.scatter(adopt_data_Xax, | ||
| + | ax = plt.gca() | ||
| + | ax.set_xlabel(' | ||
| + | ax.set_ylim([0, | ||
| + | ax.set_xlim([0, | ||
| + | ax.set_ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | |||
| + | =====Scatterplot (p.18)===== | ||
| + | <code python> | ||
| + | import matplotlib.pyplot as plt | ||
| + | import pandas as pd | ||
| + | adoption_scatterplot = pd.read_csv(' | ||
| + | adopt_data_Xax = adoption_scatterplot[' | ||
| + | adopt_data_Yax = adoption_scatterplot[' | ||
| + | plt.scatter(adopt_data_Xax, | ||
| + | ax = plt.gca() | ||
| + | ax.set_xlabel(' | ||
| + | ax.set_ylim([0, | ||
| + | ax.set_xlim([0, | ||
| + | ax.set_ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | |||
| + | |||
| + | ====== The Performance of stock mutual funds (p. 21) ====== | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | ====== Predicting the sales and airplay of popular music (p. 23)====== | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | ====== Another look at the "Old faithful" | ||
| + | |||
| + | Modified the bins of the both histograms: | ||
| + | The Histogram is reliable for the "Old faithful" | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ====== Productivity versus quality in the assembly plant (p. 25)====== | ||
| + | |||
| + | |||
| + | ===== Scatterplot of Productivity vs Quality (p. 26) ===== | ||
| + | <code Python> | ||
| + | import pandas as pd | ||
| + | import matplotlib.pyplot as plt | ||
| + | scatter_plot = pd.read_csv(' | ||
| + | productivity_Y = scatter_plot[' | ||
| + | quality_X = scatter_plot[' | ||
| + | plt.scatter(productivity_Y, | ||
| + | ax = plt.gca() | ||
| + | ax.set_Xlabel(' | ||
| + | ax.set_Ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | |||
| + | =====Scatter Plot of PRODJAPN vs QUALJAPN (p. 27) ===== | ||
| + | |||
| + | <code Python> | ||
| + | import pandas as pd | ||
| + | import matplotlib.pyplot as plt | ||
| + | scatter_plot = pd.read_csv(' | ||
| + | productivity_Y = scatter_plot[' | ||
| + | quality_X = scatter_plot[' | ||
| + | plt.scatter(productivity_Y, | ||
| + | ax = plt.gca() | ||
| + | ax.set_Xlabel(' | ||
| + | ax.set_Ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | =====Scatter Plot of PRODNONJ cs QUALNONJ (p. 27)===== | ||
| + | <code Python> | ||
| + | import pandas as pd | ||
| + | import matplotlib.pyplot as plt | ||
| + | scatter_plot = pd.read_csv(' | ||
| + | productivity_Y = scatter_plot[' | ||
| + | quality_X = scatter_plot[' | ||
| + | plt.scatter(productivity_Y, | ||
| + | ax = plt.gca() | ||
| + | ax.set_Xlabel(' | ||
| + | ax.set_Ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== Scatterplot of productivity VS quality (p. 28) ===== | ||
| + | <code python> | ||
| + | import pandas as pd | ||
| + | import matplotlib.pyplot as plt | ||
| + | scatter_plot = pd.read_csv(' | ||
| + | productivity_Y = scatter_plot[' | ||
| + | quality_X = scatter_plot[' | ||
| + | plt.scatter(productivity_Y, | ||
| + | ax = plt.gca() | ||
| + | ax.set_Xlabel(' | ||
| + | ax.set_Ylabel(' | ||
| + | ax.set_title(' | ||
| + | plt.show() | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Productivity versus quality in the assembly plant (p.29) ===== | ||
| + | |||
| + | It worked the first time but now it doesn' | ||
| + | |||
| + | <code python> | ||
| + | #1 | ||
| + | import matplotlib.pyplot as plt | ||
| + | import pandas as pd | ||
| + | data_comparison = pd.read_csv(' | ||
| + | non_japanese = data_comparison.loc[data_comparison[' | ||
| + | japanese = data_comparison.loc[data_comparison[' | ||
| + | plt.boxplot([non_japanese[' | ||
| + | plt.show() | ||
| + | |||
| + | #2 | ||
| + | import matplotlib.pyplot as plt | ||
| + | import pandas as pd | ||
| + | data_comparison = pd.read_csv(' | ||
| + | non_japanese = data_comparison.loc[data_comparison[' | ||
| + | japanese = data_comparison.loc[data_comparison[' | ||
| + | plt.boxplot([non_japanese[' | ||
| + | plt.show() | ||
| + | </ | ||
python/first_course_statistics.1476682908.txt.gz · Dernière modification : de fberetta
