如何將一列多種資料型別的資料拆分?

時間 2021-07-13 12:24:03

1樓:黃春林

看你的圖,應該是excel的,那麼就選擇excel的方式處理。

樓下有仁兄給出了截圖,他就是用的excel自帶的分列功能,在A列後面新增8列,然後要用2次分列,第一次用-做分隔符,第二次用:做分隔符,注意別被覆蓋了。

使用分列功能,被分列的列後面要預留足夠的空白列,不然後覆蓋後面的列。

2樓:Wanhui

如果用R的話,可以考慮使用dplyr 的separate function

Separate a character column into multiple columns using a regular expression separator

separate(data, col, into, sep = "[^[:alnum:]]+", remove = TRUE,

convert = FALSE, extra = "warn", fill = "warn", ...)

data

A data frame.

colColumn name or position. This is passed to tidyselect::vars_pull()

.This argument is passed by expression and supports quasiquotation (you can unquote column names or column positions).

into

Names of new variables to create as character vector. Use NA to omit the variable in the output.

sepSeparator between columns.

If character, is interpreted as a regular expression. The default value is a regular expression that matches any sequence of non-alphanumeric values.

If numeric, interpreted as positions to split at. Positive values start at 1 at the far-left of the string; negative value start at -1 at the far-right of the string. The length of sep should be one less than into.

remove

If TRUE, remove input column from output data frame.

convert

If TRUE, will run type.convert()

with as.is = TRUE on new columns. This is useful if the component columns are integer, numeric or logical.

NB: this will cause string "NA"s to be converted to NAs.

extra

"warn" (the default): emit a warning and drop extra values.

"drop": drop any extra values without a warning.

"merge": only splits at most length(into)

times

fill

"warn" (the default): emit a warning and fill from the right

"right": fill with missing values on the right

"left": fill with missing values on the left

鍊錶是一種資料結構還是資料型別?

新木 看其他答主說的一本正經的,其實很沒必要。我之前也很想一本正經理清這2個概念,查了很多資料,最後得出的結論是 這2個概念本來就已經被搞混亂了,很多書上在只說乙個的時候說的頭頭是道,但一旦涉及到二者的比較與區別,就完全是自相矛盾的了。因此我現在更願意關注通俗的使用上了。資料結構強調演算法 非固有 ...

PHP為什麼不將函式作為一種資料型別來使用呢?

三色院堇子的老公 因為PHP開發者認為call user func函式用起來挺好的,沒什麼問題,字串引數就字串引數咯,寫錯字串自己改咯。PS.PHP沒有強大完善的物件系統 哈哈哈哈哈哈哈哈哈! 你問的不是太清楚,我給你提供一些相關的方法吧。在函式內部,可以使用魔術變數 FUNCTION 來獲取函式名...

如何在excel中從一列從小到大的資料中找到與目標值最接近的數值?

聖誕老人吼吼吼 要在資料列中查詢與目標值最接近的匹配項,請在Excel 中使用 INDEX MATCH ABS 和 MIN 使用Excel 中的VLOOKUP 函式查詢近似匹配項。示例檔案 closest match.xlsx 1 Excel中的ABS函式返回乙個數字的絕對值。2.要計算目標值與資料...