Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryan-hill/fdcf3d4c0dcb201cfc6d47fc37f6af78 to your computer and use it in GitHub Desktop.
Save ryan-hill/fdcf3d4c0dcb201cfc6d47fc37f6af78 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
#Read in .csv file
nlcd = pd.read_csv('NLCD2011_FINAL.csv')
#Select desired columns - selects 1st column and then 23rd column to end
nlcd = nlcd.iloc[:, np.r_[:1, 23:len(nlcd.columns)]]
#Strip out 'Ws' string from column names that contain it
newnames = [w.replace('Ws', '') for w in nlcd.columns]
#rename columns
nlcd.columns = newnames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment