100
2187
0.6666666666666666
-34
2026-04-09
python3 -m pip install pandas plotly statsmodels
When you open VS Code and start a Python Interactive window, it acts like the R Console.
Working with Scripts vs. Notebooks
Python follows standard order of operations (PEMDAS).
=.<- operator in Python.Assign a single value:
y and assign it the value of 8.c that is a list of values 15 through 20.d that is a list containing 16, 17, 18, 19, and 22.Hint: Python’s range(start, stop) stops before the stop number!
().. notation (e.g., np.mean()).help() or ?:
help(np.mean) or np.mean? in your console will pull up the documentation.TypeError, paste it into the chat to see a breakdown.iris dataset in PythonTo use datasets in Python, we use the pandas library.
View the first few rows:
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
Get data types and info:
<class 'pandas.DataFrame'>
RangeIndex: 150 entries, 0 to 149
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 sepal_length 150 non-null float64
1 sepal_width 150 non-null float64
2 petal_length 150 non-null float64
3 petal_width 150 non-null float64
4 species 150 non-null str
dtypes: float64(4), str(1)
memory usage: 6.0 KB
Summary statistics:
sepal_length sepal_width petal_length petal_width
count 150.000000 150.000000 150.000000 150.000000
mean 5.843333 3.057333 3.758000 1.199333
std 0.828066 0.435866 1.765298 0.762238
min 4.300000 2.000000 1.000000 0.100000
25% 5.100000 2.800000 1.600000 0.300000
50% 5.800000 3.000000 4.350000 1.300000
75% 6.400000 3.300000 5.100000 1.800000
max 7.900000 4.400000 6.900000 2.500000
Get dimensions:
. (The Python equivalent of $). or [''].DataFrame.ColumnName or DataFrame['ColumnName'].0 0.2
1 0.2
2 0.2
3 0.2
4 0.2
...
145 2.3
146 1.9
147 2.0
148 2.3
149 1.8
Name: petal_width, Length: 150, dtype: float64
0 0.2
1 0.2
2 0.2
3 0.2
4 0.2
...
145 2.3
146 1.9
147 2.0
148 2.3
149 1.8
Name: petal_width, Length: 150, dtype: float64
IndentationError - Python cares about spaces at the start of lines!
NameError - Usually means you misspelled a variable or haven’t run the cell where it was defined.
SyntaxError - You might be missing a closing parenthesis ) or a quote ".
Python 02 Slides