Answer the question
In order to leave comments, you need to log in
How to iterate over a dataframe?
There is a dataframe data
(in the picture).
I want to: replace type {} in the values of each column with just {}. For example, type 5 by 5.
As planned to implement: make a generator that runs through the values of each column and leaves only a number for split.
Implementation:
columns_names = data.columns
def columns_gen(data, column_name):
for value in data[column_name].values:
if type(value) == str:
value = value.split()[1]
yield value
for column_name in columns_names:
columns_gen(data, column_name)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question