Intenta eliminar la primera fila de Python?

Bloc

Intenta eliminar la primera fila de Python?

Intenta eliminar la primera fila de Python?

Hola, tinc algunes dades en format CSV, així és com es veu a la part superior.



Tinc un codi molt senzill que només està destinat a eliminar la primera fila:



import numpy as np import pandas as pd data = pd.read_csv('mydata.csv') data = data.drop(data.columns[[0]],axis=0) data.to_csv('mydata2.csv') 

Tanmateix, quan s'executa, rebo aquest error:

Warning (from warnings module): File 'C:/Users/george/Desktop/testing/output/PIVOTING.py', line 1 DtypeWarning: Columns (6) have mixed types. Specify dtype option on import or set low_memory=False. 

Traceback (most recent call last):
File C:/Users/george/Desktop/testing/output/PIVOTING.py, line 5, in
data = data.drop(data.columns[[0]],axis=0)
File C:Python27libsite-packagespandascore frame.py , line 3697, in drop
errors=errors)
File C:Python27libsite-packagespandascore generic.py , line 3111, in drop
obj = obj._drop_axis(labels, axis, level=level, errors=errors)
File C:Python27libsite-packagespandascore generic.py , line 3143, in _drop_axis
new_axis = axis.drop(labels, errors=errors)
File C:Python27libsite-packagespandascoreindexes base.py , line 4404, in drop
‘{} not found in axis’.format(labels[mask]))
KeyError: [‘C’] not found in axis




aplicació d'escriptori raptr segura

#python #numpy #pandas