Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas drop unnamed columns

df = df.loc[:, ~df.columns.str.contains('^Unnamed')]

In [162]: df
Out[162]:
   colA  ColB  colC  colD  colE  colF  colG
0    44    45    26    26    40    26    46
1    47    16    38    47    48    22    37
2    19    28    36    18    40    18    46
3    50    14    12    33    12    44    23
4    39    47    16    42    33    48    38
Comment

drop all unnamed columns pandas

df.drop(df.columns[df.columns.str.contains('unnamed',case = False)],axis = 1, inplace = True)
Comment

remove unnamed columns pandas

df2.columns.str.match("Unnamed")
df2.loc[:,~df2.columns.str.match("Unnamed")]
Comment

PREVIOUS NEXT
Code Example
Python :: how to delete everything on a file python 
Python :: positive lookahead regex python 
Python :: dataclass post init 
Python :: python remove directory not empty 
Python :: flask for loops 
Python :: all possible substring in python 
Python :: pandas from series to dataframe 
Python :: python list minus list 
Python :: write to file python 3 
Python :: usong brave browser pyhton 
Python :: jupyter notebook check memory usage 
Python :: python how to return max num index 
Python :: matplotlib add legend axis x 
Python :: python get time difference in milliseconds 
Python :: static dir in django python 
Python :: python test if string is int 
Python :: elon son name 
Python :: python for with iterator index 
Python :: show all rows with nan for a column value pandas 
Python :: The path python2 (from --python=python2) does not exist 
Python :: flask clear session 
Python :: django get user model funciton 
Python :: reduce in python 
Python :: pyqt display math 
Python :: python rickroll code 
Python :: force two decimal places python 
Python :: sqrt python 
Python :: pandas replace nan 
Python :: python if not path exist make path 
Python :: knn classifier python example 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =