My Python/Pandas note for data processing
Sang's personal Python pandas note.
This is my personal Python
import numpy as np
import pandas as pd
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)
pd.Timestamp("2021-03-07",tz='America/Indianapolis').dayofweek
import pytorch
x = [1,2,3,4,5,4,3]
["Good" if i>=4 else "Neutral" if i==3 else "Bad" for i in x]
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:])