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

delete unnamed 0 columns

df.drop(df.filter(regex="Unnamed"),axis=1, inplace=True)
Comment

delete unnamed coloumns in pandas

# Best method so far.
df = df.loc[:, ~df.columns.str.contains('^Unnamed')]
Comment

get rid of unnamed column pandas

df.to_csv(path, index=False)
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 :: check all python versions ubuntu 
Python :: unzip python 
Python :: pandas describe get mean min max 
Python :: streamlit dropdown 
Python :: install chromedriver ubuntu python 
Python :: update python in cmd 
Python :: combinations python 
Python :: django gunicorn static file not found 
Python :: sort by index pandas 
Python :: Addition/subtraction of integers and integer-arrays with DatetimeArray is no longer supported 
Python :: how to add and subtract days datetime python 
Python :: scientific notation to decimal python 
Python :: removing a channel from aconda 
Python :: python get size of file 
Python :: How to make an simple python client 
Python :: python project ideas 
Python :: print progress without next line python 
Python :: python print without space 
Python :: python discord input 
Python :: how to make index column as a normal column 
Python :: django delete session 
Python :: discord.py check if user has role 
Python :: md5 hash python 
Python :: pyqt latex 
Python :: django setup allowed hosts 
Python :: python get everything between two characters 
Python :: pandas groupby get all but first row 
Python :: python continue vs pass 
Python :: convert every element in list to string python 
Python :: freq count in python 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =