type(5)
int
Introducing Python
Massive Data Institute, Georgetown University
January 6, 2022
“Python is a
BeautifulSoup
, Selenium
, Scrapy
, Django
, Flask
Pandas
, NumPy
, Matplotlib
, SciPy
Scikit-Learn
, TensorFlow
, Keras
, PyTorch
, LightGBM
OpenCV
, Pillow
TkinterA
, PygameA
, PyOpenGL
JupyterLab
<int>
<float>
<str>
<bool>
+
plus-
minus*
multiply/
divide==
equal (<
, >
, <=
, >=
)and
or
not
{1: 'C++', 3: 'R', 2: 'python', 4: 'Julia'}
delhi = {'city':"Delhi", 'country':"India", 'pop': 28514000}
shanghai = {'city':"Shanghai", 'country':"China", 'pop': 25582000}
megacities= [tokyo,delhi,shanghai]
print(megacities)
[{'city': 'Tokyo', 'country': 'Japan', 'pop': 37468000}, {'city': 'Delhi', 'country': 'India', 'pop': 28514000}, {'city': 'Shanghai', 'country': 'China', 'pop': 25582000}]
#! pip install requests pandas matplotlib
import requests
import io
import pandas as pd
import matplotlib.pyplot as plt
#Predictit data
url = "https://www.predictit.org/Resource/DownloadMarketChartData?marketid=7326×pan=90d"
#Download data
web_response = requests.get(url, timeout = 30, stream = True)
#Read data
f = io.BytesIO(web_response.content)
speaker_bet = pd.read_csv(f)
ContractName Date OpenSharePrice HighSharePrice \
0 Trump 10/8/2022 12:00:00 AM $0.03 $0.04
1 Scalise 10/8/2022 12:00:00 AM $0.04 $0.04
2 McCarthy 10/8/2022 12:00:00 AM $0.75 $0.75
... ... ... ... ...
1437 Ocasio-Cortez 1/5/2023 12:00:00 AM $0.01 $0.01
1438 Clark 1/5/2023 12:00:00 AM $0.01 $0.01
1439 Banks 1/5/2023 12:00:00 AM $0.01 $0.02
LowSharePrice CloseSharePrice TradeVolume
0 $0.03 $0.04 340
1 $0.04 $0.04 565
2 $0.74 $0.75 1203
... ... ... ...
1437 $0.01 $0.01 15
1438 $0.01 $0.01 0
1439 $0.01 $0.01 80290
[1440 rows x 7 columns]
BeautifulSoup
Le Bao · AU Winter Institute · https://baole.io/