This is my personal Python

Pandas

import numpy as np
import pandas as pd

Indexing

Naming

Group

Timestamp

print(pd.Timestamp("2021-03-07",tz='America/Indianapolis').week)
print(pd.Timestamp("2021-03-07",tz='America/Indianapolis').dayofweek)
print(pd.Timestamp("2021-03-08",tz='America/Indianapolis').week)
print(pd.Timestamp("2021-03-08",tz='America/Indianapolis').dayofweek)
9
6
10
0
pd.Timestamp("2021-03-07",tz='America/Indianapolis').dayofweek
6
import pytorch
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-20-d35c46f8d1a2> in <module>
----> 1 import pytorch

ModuleNotFoundError: No module named 'pytorch'

Python

List comprehension with if

x = [1,2,3,4,5,4,3]
["Good" if i>=4 else "Neutral" if i==3 else "Bad" for i in x]
['Bad', 'Bad', 'Neutral', 'Good', 'Good', 'Good', 'Neutral']

OOP simple example

class Animal:
    def __init__(self, name):
        self.name = name

# Create a class Mammal, which inherits from Animal
class Mammal(Animal):
    def __init__(self, name, animal_type):
        self.animal_type = animal_type
        self.name=name

# Instantiate a mammal with name 'Daisy' and animal_type 'dog': daisy
daisy = Mammal("Daisy", "dog")

# Print both objects
print(daisy)
print(daisy.animal_type)
print(daisy.name)
print(dir(daisy)[-3:])
<__main__.Mammal object at 0x00000195B15200D0>
dog
Daisy
['__weakref__', 'animal_type', 'name']