Methoden und Pakete

Python für MATLAB-Anwender

Justin Kiggins

Product Manager

Methoden sind Funktionen an Variablen

  • Abhängig vom Variablentyp
  • Mit Punkt aufgerufen
yelling = "WHY ARE YOU YELLING?"
whispering = yelling.lower()
print(whispering)
why are you yelling?
Python für MATLAB-Anwender

Die Methode .format()

n_avocados = 1765
message = "I have {} avocados!".format(n_avocados)

print(message)
I have 1765 avocados!
Python für MATLAB-Anwender

Python-Pakete

NumPy-Logo

matplotlib-Logo

pandas-Logo

Python für MATLAB-Anwender
import math

math.pi
3.141592653589793
math.log(0.9)
-0.10536051565782628

Teil eines Pakets importieren:

from math import log
log(0.9)
-0.10536051565782628
Python für MATLAB-Anwender

Paket-Aliase

import datetime as dt

birth_date = dt.datetime(1961,8,4)
# Importiere NumPy mit gängigem Alias import numpy as np x = np.ndarray([1, 2, 3])
# Importiere pandas mit gängigem Alias import pandas as pd df = pd.DataFrame()
# Importiere Matplotlibs pyplot mit gängigem Alias import matplotlib.pyplot as plt plt.show()
# Importiere Seaborn mit gängigem Alias import seaborn as sns sns.set_theme()
Python für MATLAB-Anwender

Schauen wir uns nützliche Methoden und Pakete an

Python für MATLAB-Anwender

Preparing Video For Download...