OSError Traceback (most recent call last)
<ipython-input-81-601b7bf65236> in <module>
9 for sta in range(len(station)):
10 df = pd.read_csv(r"C:\Users\srp2021\result_for_gz{}\{}POI{}.csv".format(year[i],station[sta],year[i]),encoding="utf-8")
---> 11 cloud(only(df),station)
<ipython-input-80-f1bd0278bcb8> in cloud(count, station)
4 # 参数分别是指定字体、背景颜色、最大的词的大小、使用给定图作为背景形状
5 wc = WordCloud(font_path='c:\\windows\\Fonts\\simhei.ttf', background_color='white', max_words=100) #, mask=graph)
----> 6 wc.generate_from_frequencies(count) # 根据给定词频生成词云
7 #image_color = ImageColorGenerator(graph)
8 plt.imshow(wc)
D:\ana\envs\tensorflow\lib\site-packages\wordcloud\wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
499 font, orientation=orientation)
500 # get size of resulting text
--> 501 box_size = draw.textsize(word, font=transposed_font)
502 # find possible places using integral image:
503 result = occupancy.sample_position(box_size[1] + self.margin,
D:\ana\envs\tensorflow\lib\site-packages\PIL\ImageDraw.py in textsize(self, text, font, spacing, direction, features, language, stroke_width)
567 if font is None:
568 font = self.getfont()
--> 569 return font.getsize(text, direction, features, language, stroke_width)
570
571 def multiline_textsize(
D:\ana\envs\tensorflow\lib\site-packages\PIL\ImageFont.py in getsize(self, text, *args, **kwargs)
768
769 def getsize(self, text, *args, **kwargs):
--> 770 w, h = self.font.getsize(text)
771 if self.orientation in (Image.ROTATE_90, Image.ROTATE_270):
772 return h, w
D:\ana\envs\tensorflow\lib\site-packages\PIL\ImageFont.py in getsize(self, text, direction, features, language, stroke_width)
428 # vertical offset is added for historical reasons
429 # see https://github.com/python-pillow/Pillow/pull/4910#discussion_r486682929
--> 430 size, offset = self.font.getsize(text, "L", direction, features, language)
431 return (
432 size[0] + stroke_width * 2,
OSError: invalid argument
|