Overview
I'd like to return the value of a column in a csv based upon a search. I'm most of the way there, but do not understand why I'm getting the result I am, and how to fix it up. I'm using pandas 0.25 to read in the csv. This version was chosen rather than 1.03 due to some issues with 1.03 and geopandas interaction later on.
The question: Why am I receiving a row number, how do I omit the row number from the returned result?
A subset of my code is as follows:
import numpy as np
import os
import pandas as pd
code_ITS_path = 'input_ITS.csv'
code_ITS = pd.read_csv(code_ITS_path,sep=',')
for trial_name in code_ITS.Trial_Name[code_ITS.Trial_Name.str.contains("Trial")]:
scenario_name = code_ITS.Scenario_Name[code_ITS.Trial_Name.str.contains(trial_name)]
print("Trial Name is " + trial_name)
print("Scenario Name is " + scenario_name)
Problem
The results that are being returned appear to include the row number before "Scenario Name is" Unfortunately this is causing me issues later on. So, printing out trial_name works, but printing out scenario_name shows the problem. The issue here is the presence of "24 " before the scenario_name. eg:
Trial Name is 500_10_3_Trial_24
24 Scenario Name is 500_10_3_24
Desired Outcome
What I need to return: Ie, scenario_name does not contain the line number and tab indent
Scenario Name is 500_10_3_25
Example Data
An example of the CSV:
Agency,Region,Requesting_Group,Scenario_Name,Type,Scenario_Description,Trial_Name,Notes
15,Main,,500_10_3_B,Operational,Testing,500_10_3_BestEstimate,None
15,Main,,500_10_3_1,Operational,Testing,500_10_3_Trial_1,None
15,Main,,500_10_3_2,Operational,Testing,500_10_3_Trial_2,None
15,Main,,500_10_3_3,Operational,Testing,500_10_3_Trial_3,None
15,Main,,500_10_3_4,Operational,Testing,500_10_3_Trial_4,None
15,Main,,500_10_3_5,Operational,Testing,500_10_3_Trial_5,None
15,Main,,500_10_3_6,Operational,Testing,500_10_3_Trial_6,None
15,Main,,500_10_3_7,Operational,Testing,500_10_3_Trial_7,None
15,Main,,500_10_3_8,Operational,Testing,500_10_3_Trial_8,None
15,Main,,500_10_3_9,Operational,Testing,500_10_3_Trial_9,None
15,Main,,500_10_3_10,Operational,Testing,500_10_3_Trial_10,None
15,Main,,500_10_3_11,Operational,Testing,500_10_3_Trial_11,None
15,Main,,500_10_3_12,Operational,Testing,500_10_3_Trial_12,None
15,Main,,500_10_3_13,Operational,Testing,500_10_3_Trial_13,None
15,Main,,500_10_3_14,Operational,Testing,500_10_3_Trial_14,None
15,Main,,500_10_3_15,Operational,Testing,500_10_3_Trial_15,None
15,Main,,500_10_3_16,Operational,Testing,500_10_3_Trial_16,None
15,Main,,500_10_3_17,Operational,Testing,500_10_3_Trial_17,None
15,Main,,500_10_3_18,Operational,Testing,500_10_3_Trial_18,None
15,Main,,500_10_3_19,Operational,Testing,500_10_3_Trial_19,None
15,Main,,500_10_3_20,Operational,Testing,500_10_3_Trial_20,None
15,Main,,500_10_3_21,Operational,Testing,500_10_3_Trial_21,None
15,Main,,500_10_3_22,Operational,Testing,500_10_3_Trial_22,None
15,Main,,500_10_3_23,Operational,Testing,500_10_3_Trial_23,None
15,Main,,500_10_3_24,Operational,Testing,500_10_3_Trial_24,None
15,Main,,500_10_3_25,Operational,Testing,500_10_3_Trial_25,None