Relative Content

Tag Archive for pythonpandasstringdataframe

Convert range of numbers to average in a pandas dataframe cell

I have a pandas dataframe read from large spreadsheets provided through a survey. In a column that expects float input, some of the cell entries are expressed as “n1-n2” (where n1 and n2 are numbers). I need to go through such columns and convert each such instance to (n1+n2)/2. Can someone suggest a lambda apply function for this to do this in the most pythonic way?

Convert range of numbers to average in a pandas dataframe

I have a pandas dataframe read from large spreadsheets provided through a survey. In a column that expects float input, some of the cell entries are expressed as “n1-n2” (where n1 and n2 are numbers). I need to go through such columns and convert each such instance to (n1+n2)/2. Can someone suggest a lambda apply function for this to do this in the most pythonic way?