My script below is returning the error 'NoneType' and i can't figure out why.
project_id
abcd
jklm
NEW COLUMN
study_id
abcd_1
jklm_1
Any help is appreciated thank you!
import pandas as pd from os import listdir from os.path import isfile, join onlyfiles = [f for f in listdir('.') if isfile(join('.', f))] print(onlyfiles) #add new column for file in onlyfiles: if file[:1] != '.' and file[-5:] != 'ipynb': print(file) bls_data = pd.read_csv(file) df['study_id'] = df['project_id'].astype(str) + '_1' df = df.to_csv('07newcolumn/' + file[:-5] + 'vF.csv', index=True)Im essentially looking to create a new column called "study_id" that takes an existing column (project_id) and adds "_1" at the end of each row value. So for example right beside project_id, the script would create a new new column called study_id that adds "_1" at the end of each row value.
project_id
abcd
jklm
NEW COLUMN
study_id
abcd_1
jklm_1
Any help is appreciated thank you!
Larz60+ write Sep-30-2022, 02:34 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts