Python Forum
How get row index of matching row in column 0
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How get row index of matching row in column 0
#1
Hi,

I have a csv file as below:

inter value,70				
time interval[min],20				
dose_trigger value,-23				
					
					
warning_linit1,36				
warning limit2,15				
cooling time [hrs],2				
cooling number[#],30				
					
					
					
Trail_number,initila,final,middle,max,min
Trial_20157832,1,23,14,28,1
Standard,0,5,2.6,5,0
Trial_20037924,	2,13,17,20,0
Trial_20637924,6,18,19,17,3
I want to get the row index of "Trail_number" in column zero (here row8).

1. Extract the data from row zero to row7 (rows befor Trail_number row),and write to 'intial.csv'
2. Extract the data from row Trail_number(here row8) to end in to a 'final.csv'


I use the below code, but I am getting error in getteing row index.

import pandas as pd
import numpy as np
rw_data=pd.read_csv(r'D:\Mekala_Backupdata\PythonCodes\raw_WEHP02.csv')

idx1=~(rw_data.where(rw_data[0]=='Trail_number')).isnull().all()
error:

KeyError: 0
Reply


Messages In This Thread
How get row index of matching row in column 0 - by Sri - Apr-09-2019, 01:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Removing the index column from df bnadir55 7 3,130 Apr-05-2022, 02:49 PM
Last Post: snippsat
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,347 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  Index error - columns vs non-column Vinny 3 4,957 Aug-09-2021, 04:46 PM
Last Post: snippsat
Question Matching variable to a list index Gilush 17 5,955 Nov-30-2020, 01:06 AM
Last Post: Larz60+
  How to define index column name using df.to_csv SriRajesh 0 1,785 Feb-13-2020, 03:45 PM
Last Post: SriRajesh
  How to get row row index of matching row SriRajesh 0 1,271 Feb-13-2020, 02:35 PM
Last Post: SriRajesh
  How to ger matching rows data based on index columns SriRajesh 1 2,239 Mar-08-2019, 11:05 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020