Last active
November 22, 2020 06:08
-
-
Save nickinack/b060570ed8dcf1bf1f6d57e588ff2d53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1 = pd.read_csv("communities.data" , header=None) | |
def read_header(filename): | |
''' | |
Given a filename containing headers, extract the headers and assign it to df | |
''' | |
header_list = [] | |
with open(filename) as f: | |
for line in f: | |
if "@attribute" in line: | |
header_list.append(line.split(" ")[1]) | |
return header_list | |
headers = read_header("communities.names") | |
df1.columns = headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment