Skip to content

Instantly share code, notes, and snippets.

@alpercalisir
Created November 15, 2018 20:18
Show Gist options
  • Save alpercalisir/c90897a5c8a15665a2171ecc904686ec to your computer and use it in GitHub Desktop.
Save alpercalisir/c90897a5c8a15665a2171ecc904686ec to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
fields = ['FACE_X','FACE_Y','FACE_WIDTH','FACE_HEIGHT']
df = pd.read_csv('a.txt', usecols=fields)
df['FACE_WIDTH']=df['FACE_X']+df['FACE_WIDTH']
df['FACE_HEIGHT']=df['FACE_Y']+df['FACE_HEIGHT']
# Some indexes may contain NAN
# All contain NA or inf and not possible to convert integer
# Shows the Null index
# for index, row in df['FACE_X'].iteritems():
# if row != row:
# print('index:', index, 'isnull')
# What needs to be done if we have NAN
# df['FACE_X'].fillna(0).astype(int)
np.savetxt(r'b.txt', df.values, fmt='%d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment