I have encountered some value error when input txt file into python.
the txt file called "htwt.txt", and contain the below data:
Ht Wt
169.6 71.2
166.8 58.2
157.1 56
181.1 64.5
158.4 53
165.6 52.4
166.7 56.8
156.5 49.2
168.1 55.6
165.3 77.8
When I typed the below code, and value errors are occurred.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
import statsmodels.api as sm
from statsmodels.formula.api import ols
os.chdir("/Users/James/Desktop/data/")
data1=np.loadtxt("htwt.txt")
df1=pd.DataFrame(data1)
ValueError: could not convert string to float: 'Ht'
May I know what should the correct code so that it can be converted to the data frame? thanks.