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

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 :: flask sqlalchemy query specific columns 
Python :: sort a series pandas 
Python :: concatenate dataframes pandas without duplicates 
Python :: remove character from string by index in python 
Python :: python groupby sum single columns 
Python :: python turtle commands 
Python :: armstrong python 
Python :: python opencv draw rectangle with mouse 
Python :: template string python 
Python :: unicodedecodeerror file read 
Python :: Plot regression line from sklearn 
Python :: resto division python 
Python :: how download youtube video in python 
Python :: How to generate all the permutations of a set of integers, in Python? 
Python :: excel get unique values from column formula 
Python :: how to delete a file in python 
Python :: how to import file from another directory in python 
Python :: rnadom number python 
Python :: basic tkinter gui 
Python :: multiple variables in for loop python 
Python :: timestamp to date time till milliseconds python 
Python :: __str__() 
Python :: python replace character in string 
Python :: turn df to dict 
Python :: python list comprehension cartesian product 
Python :: np random seed 
Python :: get tail of dataframe pandas 
Python :: pd.read_excel 
Python :: python request response json format 
Python :: multiprocessing a for loop python 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =