Here I am jus extracting a csv file and reading the "TV"values, calculating average and printing using tensorflow. But I am getting "AttributError" list has no attribute 'size' ". Can anyone please help me? Thanks in advance.
import tensorflow as tf
import pandas
csv = pandas.read_csv("Advertising.csv")["TV"]
t = tf.constant(list(csv))
r = tf.reduce_mean(t)
sess = tf.Session()
s = list(csv).size
fill = tf.fill([s],r)
f = sess.run(fill)
print(f)
s = len(csv)instead ofs = list(csv).sizesize. The normal way to get the length of a sized object is to uselen(object)instead.Seriesobject, then just use the.sizeattribute on that directly. Pandas and numpy translate most actions into actions on the contents, which is why they are an exception to the normallen()usage.pandas.read_csv("Advertising.csv")["TV"]returns a Pandas.Series object andlen(Pandas.Series)returns its length. I can't imagine how can it return a list...