Forum Discussion
Syndicate_Admin
4 years agoAdministrator
Error de objeto no es iterable en PowerBI Dekstop Python
Tengo un conjunto de datos de libros. No incluye la columna "año" en cuanto a cuándo se lanzó un libro.
Por lo tanto, con la biblioteca isbnlib Python quiero lograr algo como esto en PowerBI:
Esto es lo que he intentado hasta ahora:
import isbnlib
from progressbar import ProgressBar
def bookdata(dataset):
year=[]
pbar = ProgressBar()
for isbn in pbar(dataset.isbn13):
details = isbnlib.meta(isbn)
year.append(details['Year'])
return year
def plot_author_chart(author_df):
year = bookdata(author_df)
author_df = final_df(author_df, year)
author_df.dropna(0, inplace=True)
author_df = author_df[author_df['Year'].str.isnumeric()]
author_df = author_df.set_index('title')
author_df = author_df[author_df.Year !='0']
plt.figure(figsize=(15,15))
plt.xticks(rotation=30)
ax = sns.barplot( author_df['Year'], author_df['average_rating'], palette='deep')
ax.set_title("Average rating of books over time, "+ author_df.authors[1])
plt.xticks(rotation=30)
return ax
def final_df(df1, l):
year_df = pd.DataFrame(l, columns=['Year'])
df1 = df1.reset_index(drop=True)
final = df1[['authors', 'average_rating', 'title']].join(year_df)
return final
authors= ['Stephen King', 'Agatha Christie', 'Dan Brown', 'J.K. Rowling']
author_df = dataset[dataset['authors']==authors[0]]
author_df = author_df[author_df['language_code']=='eng']
plot_author_chart(author_df)
Siempre recibo el mismo error, que es:
No entiendo el problema. ¿Puedes ayudarme, por favor? Soy nuevo en PowerBI.
No RepliesBe the first to reply