text_plain_output_1.png
import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df_train = pd.read_csv('../input/train.csv')
df_test = pd.read_csv('../input/test.csv')

lattice_columns = ['lattice_vector_1_ang', 'lattice_vector_2_ang', 'lattice_vector_3_ang', 'lattice_angle_alpha_degree', 'lattice_angle_beta_degree', 'lattice_angle_gamma_degree']
df_train.loc[0, lattice_columns]

def get_xyz_data(filename):
    pos_data = []
    lat_data = []
    with open(filename) as f:
        for line in f.readlines():
            x = line.split()
            if x[0] == 'atom':
                pos_data.append([np.array(x[1:4], dtype=np.float), x[4]])
            elif x[0] == 'lattice_vector':
                lat_data.append(np.array(x[1:4], dtype=np.float))
    return (pos_data, np.array(lat_data))

idx = df_train.id.values[0]
fn = '../input/train/{}/geometry.xyz'.format(idx)
train_xyz, train_lat = get_xyz_data(fn)

idx = df_test.id.values[0]
fn = '../input/test/{}/geometry.xyz'.format(idx)
test_xyz, test_lat = get_xyz_data(fn)

df_test.loc[0, lattice_columns]