<jupyter_start><jupyter_text>120 mins- python libraries/module- keywords in python- complex data structures- work with files - pandas- visualization - matplotlib<jupyter_code>!ls
!pip install pandas matplotlib
math
import math
math
help(math)
math.log
math.log10(1000)
import math as m
m.log
from math import log10
log10
log10(1000)
from math import *
sin
from random import choice
choice
shuffle
from random import *
shuffle
print('Doris')
####!!!! danger
print = 34
print('Doris')
print
math
math = 90
math
math.log10(1000)
from math import log, log10
log
log10
import math
dir(math)
functions = dir(math)
type(functions[0])
functions[0]
type(functions)
len(functions)
math.log10(1000)
math.__name__
math.__doc__
functions[6]<jupyter_output><empty_output><jupyter_text>0['__doc__',1 '__file__',2 '__loader__',3 '__name__',4 '__package__',5 '__spec__',6 'acos',<jupyter_code>functions[6:10]
list_funcs = dir(functions)
list_funcs
shopping_list = ['rice', 'salt', 'broccoli', 'apple']
type(shopping_list)
len(shopping_list)
help(shopping_list.append)
shopping_list.append('sugar')
len(shopping_list)
shopping_list
help(shopping_list.insert)
shopping_list.insert(3, 'ice cream')
shopping_list
help(shopping_list.remove)
shopping_list.append('salt')
shopping_list
shopping_list.remove('salt')
shopping_list
!wget https://swcarpentry.github.io/python-novice-gapminder/files/python-novice-gapminder-data.zip
!ls
!unzip python-novice-gapminder-data.zip -d ./
!ls -s data
# if you are on windows
#!dir
import pandas as pd
help(pd)
data = pd.read_csv('data/gapminder_all.csv')
data
data.loc[0]
list(data)
data.loc[:, 'country']
data.loc[0, :] # same as data.loc[0]
data.index
print(list(data.index))
data = pd.read_csv('data/gapminder_all.csv', index_col='country')
data_error = pd.read_csv(
    'data/gapminder_all.csv', 
    index_col='index'
)
data
data.loc[0]
print(list(data.index))
data.loc['Algeria']
from rich import print
print(list(data))
data.loc[:, 'continent']
data.iloc[:,0] # data.loc[:, 'continent']
data.iloc[0:3, 0]
data.iloc[0:3, 0:3]
import matplotlib.pyplot as plt
help(plt.plot)
plot_data = data.loc['Argentina':'Ecuador', 'lifeExp_2007']
plot_data
plot_data.index
plt.plot(plot_data.index, plot_data)
plt.xticks(rotation=90)
plt.xlabel('country')
plt.ylabel('life exp')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1447084233261339, 'fraction_numerical': 0.030669546436285097, 'mean_word_length': 6.958762886597938, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '273866', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 942, 'n_tokens_neox': 902, 'n_words': 187, 'path': 'workshop/build programs with python.ipynb', 'repo_name': 'zdshaoteach/2022-03-28-upr-online', 'size': '2315'}