Я придумал решение для dataframes с произвольным количеством столбцов (в то же время только разделяя записи по одному столбцу за раз).
def splitDataFrameList(df,target_column,separator):
''' df = dataframe to split,
target_column = the column containing the values to split
separator = the symbol used to perform the split
returns: a dataframe with each entry for the target column separated, with each element moved into a new row.
The values in the other columns are duplicated across the newly divided rows.
'''
def splitListToRows(row,row_accumulator,target_column,separator):
split_row = row[target_column].split(separator)
for s in split_row:
new_row = row.to_dict()
new_row[target_column] = s
row_accumulator.append(new_row)
new_rows = []
df.apply(splitListToRows,axis=1,args = (new_rows,target_column,separator))
new_df = pandas.DataFrame(new_rows)
return new_df
Это результат неточности значений с плавающей запятой , это не относится к Haskell. Если вы не можете справиться с аппроксимацией, присущей плавающей запятой, то вы можете использовать Rational с высокой производительностью:
> import Data.Ratio
Data.Ratio> [0,1%10.. 1%1]
[0 % 1,1 % 10,1 % 5,3 % 10,2 % 5,1 % 2,3 % 5,7 % 10,4 % 5,9 % 10,1 % 1]
Чтобы забить точку дома, вот Python :
>>> 0.3
0.29999999999999999
И вот C:
void main() { printf("%0.17f\n",0.3); }
$ gcc t.c 2>/dev/null ; ./a.out
0.29999999999999999
Обратитесь к этому другому сообщению . Как он утверждает, числа с плавающей запятой не являются точными в CPU.