The following code shows an error. But it works if I remove usercols parameter.
from StringIO import StringIO
import pandas as pd
u_cols = ['page_id','web_id']
audit_trail = StringIO('''
page_id | web_id
3|0
7|3
11|4
15|5
19|6
''')
df = pd.read_csv(audit_trail, sep="|", usecols = u_cols )
ValueError: Passed header names mismatches usecols
I need to use u_cols list because the column headings are being generated dynamically.
"names" should be used instead of "usecolmns"
from StringIO import StringIO
import pandas as pd
u_cols = ['page_id','web_id']
audit_trail = StringIO('''
page_id | web_id
3|0
7|3
11|4
15|5
19|6
''')
df11 = pd.read_csv(audit_trail, sep="|", names = u_cols )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With