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 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

remove unnamed 0 column pandas

df.to_csv(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 :: python dict comprehension 
Python :: django pagination 
Python :: python scope 
Python :: Get current cursor type and color Tkinter Python 
Python :: lower case of string 
Python :: search for a word in pdf using python 
Python :: looping on string with python 
Python :: xpath starts-with and ends-with 
Python :: longest common subsequence python 
Python :: save object pickle python 
Python :: set an index to a dataframe from another dataframe 
Python :: os file size python 
Python :: create a empty dataframe 
Python :: python string to lower 
Python :: load image metadata with pil 
Python :: replace all characters in a string python 
Python :: python count how many times a character appears in a string 
Python :: python finally keyword 
Python :: automate boring stuff with python 
Python :: select python 
Python :: pivot pyspark 
Python :: length of list python 
Python :: kpss test python 
Python :: one liner if else replacement in python 
Python :: conda create environment python 3 
Python :: python image crop 
Python :: break python 
Python :: binary search python 
Python :: pretty printing using rich library in python 
Python :: python turn positive into negative 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =