Created
January 18, 2018 11:00
-
-
Save psy901/5aa480290ef47f10552a26ea5f714bc7 to your computer and use it in GitHub Desktop.
Importing columns from csv file
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
import pandas as pd | |
def read_csv(filename, num_rows): | |
# print("") | |
df = pd.read_csv(filename, encoding='latin-1', nrows=num_rows) | |
table = df[['Name', 'Country']] | |
search_terms = [] | |
# getting columns of name and country | |
for index, row in table.iterrows(): | |
name = row['Name'] | |
country = row['Country'] | |
search_terms.append(name + " " + country) | |
return search_terms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment