Reputation: 801
i have a csv as such, read it into a dataframe ,
df = pd.read_csv("sample.csv", usecols=["SupplierName', 'ContactName'])
is it possible to select say a particular row and then just a column from above df , as such
df_sub = df.iloc[1:2]
df_name = df_sub['ContactName'] or something similar
also, can i assign some other value , once i narrow it down one row/column , something like df_name['ContactName'] = 'some other name', to change the value store in that cell
SupplierID SupplierName ContactName Address City
1 Exotic Liquid Charlotte Cooper 49 Gilbert St. Londona
2 New Orleans Cajun Delights Shelley Burke P.O. Box 78934 New Orleans
3 Grandma Kelly's Homestead Regina Murphy 707 Oxford Rd. Ann Arbor
Upvotes: 0
Views: 133
Reputation: 323226
You can try with select row and column with iloc
at the same time
df_sub = df.iloc[1:2, df.columns.get_indexer(['ContactName'])]
Upvotes: 1