Skip to content

Instantly share code, notes, and snippets.

@garymanley
Created December 30, 2017 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garymanley/d4700cf63458f34e5362bba0f9c6c2f3 to your computer and use it in GitHub Desktop.
Save garymanley/d4700cf63458f34e5362bba0f9c6c2f3 to your computer and use it in GitHub Desktop.
Pandas Basics
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 28 19:46:45 2017
@author: garym
"""
#import pandas
import pandas as pd
## create dataframe from csv
dataframe = pd.read_csv(r'C:\Users\garym\Documents\PyWinAutoBlog\File\testing.csv')
## can also use from sql, html, txt, excel etc.
## print top 5 row
print(dataframe.head(5))
#Rename columns
dataframe.columns = ['Start', 'Bob', 'Colx', 'Something','Woo', 'testing']
print(dataframe.head(5))
#Drop Columns
dataframe.drop(['Start', 'Bob'], axis = 1 , inplace = True)
print(dataframe.head(5))
#Get Unique values
dfUnique = dataframe.Colx.unique()
print(dfUnique)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment