Skip to content

Instantly share code, notes, and snippets.

@ryanleeallred
Last active July 13, 2022 08:10
Show Gist options
  • Save ryanleeallred/9b97ef6a1057a5217e9a3b4001995edb to your computer and use it in GitHub Desktop.
Save ryanleeallred/9b97ef6a1057a5217e9a3b4001995edb to your computer and use it in GitHub Desktop.
Example code for BloomTech Data Science Unit 3 Sprint 1 Module 2
import pandas as pd
# Build my class of type DataFrame
# df holds a new DataFrame "object"
# when I create a new object and save it to a variable
# I say that I have "instantiated" that object
df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
if __name__ == "__main__":
# Variables that form part of an "object"
# are called "attributes"
# we will access them using "dot-notation"
print(df.shape)
print(df.dtypes)
print(df.index)
print(df.columns)
# Functions that form part of an "object
# are called "methods"
print(df.head())
print(df.describe())
print(df.null().sum())
# a method associated with a Pandas "Series" object
# aka "column"
# which lives inside of a dataframe
print(df['a'].value_counts())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment