我最近尝试从数据框中删除(“\ t”)值。
" -----------------
" General
" -----------------
set nocp "enable Vi incompatible features
filetype plugin on "per-filetype settings
set shiftwidth=2
set tabstop=2
" -----------------
" Plugins
" -----------------
execute pathogen#infect()
" ----------------
" Encoding
" ----------------
set encoding=utf-8 "utf-8 encoding
set termencoding=utf-8 "utf-8 terminal
scriptencoding utf-8
set ff=unix "unix line endings
" -----------------
" Theme
" -----------------
set t_Co=256
syntax on "syntax highlighting
set nu "show line numbers
set ru "show ruler at cursor pos
set cursorline "highlight current line
set hlsearch "highlight search results
set showmatch "matching parentheses
set gcr=n:blinkon0 "turn off blinking cursor in normal mode
" highlight the word under cursor (CursorMoved is inperformant)
highlight WordUnderCursor cterm=underline "ctermfg=7
autocmd CursorHold * exe printf('match WordUnderCursor /\V\<%s\>/', escape(expand('<cword>'), '/\'))
"statusbar
set laststatus=2
" ----------------
" Behavior
" ----------------
set ai "autoindent
set backspace=indent,eol,start "allow backspacing over everything in insert mode
set shiftround "round > < to shiftwidth
set ignorecase smartcase "ignore case, except if contains uppercase
set noerrorbells visualbell t_vb= "don't ring the bell
set incsearch "incremental search
set mouse=a "enable mouse
set mousehide "Hide the mouse cursor while typing
set virtualedit=onemore "Allow for cursor beyond last character
set sc "show incomplete commmands
set tw=72 "textwidth 72 characters
autocmd GUIEnter * set visualbell t_vb=
if has('clipboard')
if has('unnamedplus') "use + register for copy-paste when available
set clipboard=unnamed,unnamedplus
else "otherwise try to use * register
set clipboard=unnamed
endif
endif
"go
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <leader>co <Plug>(go-coverage)
"Markdown
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh']
"always start in first line in git commit messages
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
"refresh vimrc after saving
autocmd BufWritePost ~/.vimrc source %
autocmd BufWritePost ~/.vim/vimrc source %
O / P -
def FillMissing(dataFrame):
dataFrame.replace("\?",np.nan,inplace=True,regex=True)
dataFrame[:] = dataFrame.apply(lambda x: x.str.strip("\t") \
if x.dtype == "object" else x)
print(id(dataFrame))
.......
(test_df,obj,int_,float_)= FillMissing(test_df)
print(id(test_df))
通过略微修改方法,O / P改变
ID(dataFrame) - 4647827832
htn-->['yes' 'no']
dm-->['yes' 'no' ' yes']
cad-->['no' 'yes']
appet-->['good' 'poor']
pe-->['no' 'yes']
ane-->['no' 'yes']
ID(test_df) - 4647827832
O / P -
def FillMissing(dataFrame):
dataFrame.replace("\?",np.nan,inplace=True,regex=True)
***dataFrame = dataFrame.apply(lambda x: x.str.strip("\t") \
if x.dtype == "object" else x)***
print(id(dataFrame))
.......
(test_df,obj,int_,float_)= FillMissing(test_df)
print(id(test_df))
我无法理解陈述中的区别。
同时在ID(dataFrame) - 4647827832
htn-->['yes' 'no' nan]
dm-->['yes' 'no' ' yes' nan]
cad-->['no' 'yes' nan]
appet-->['good' 'poor' nan]
pe-->['no' 'yes' nan]
ID(test_df) - 4517467528
上的函数外执行条带时,它完全正常。
使用的数据快照 -
test_df