Home > Blockchain >  Edit each row of a column in a huge dataframe
Edit each row of a column in a huge dataframe

Time:12-11

I have a dataframe with some columns The first column is called TIME...in the first row of that column the time is 2022-06-01T00:00:00.0/2022-06-01T00:01:00.0 in the second row, the time is 2022-06-01T00:01:00.0/2022-06-01T00:02:00.0 I want to cut whatever exists in each row of THAT COLUMN after the /

for row in DATA['TIME']:
    for char in row:
        while char != "/" :
           continue
        else :
           break
print (column)  
 

CodePudding user response:

You can either use pandas.Series.str.split :

DATA["TIME"] = DATA["TIME"].str.split("/", expand=True)[0]

Or pandas.Series.str.extract :

DATA["TIME"] = DATA["TIME"].str.extract("(. )/", expand=False)

# Output :

print(DATA)
                    TIME
0  2022-06-01T00:00:00.0
1  2022-06-01T00:01:00.0

CodePudding user response:

for index in df.index: print(index)

  • Related