python load json file

 

..

# importing the module
import json
# Opening JSON file
with open(FileA) as json_file:
data = json.load(json_file)
print("Type:", type(data))
print('length: ', len(data))
print('first item type: ', type(data[0]))

..


Thank you.

www.marearts.com


python, pandas, to create empty data frame with same header from other df.

 

refer to code.

..

import pandas as pd
data_df = pd.read_csv('train_data.tsv', delimiter='\t')
col = list(data_df.columns)

#make empty pandas with same header
empty_df = pd.DataFrame(columns=col)
print(empty_df)

..


Thank you.

www.marearts.com

python os mkdir example code

..

if not os.path.exists(output_dir):
    os.mkdir(output_dir)

..


Thank you.

www.marearts.com