Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python Statistics QQ Group chat text Visualization Analysis of Class 180

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

How to use Python statistics class 180 QQ group chat text visualization analysis, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Today is August third.

The habitual students who review around them leave.

There are fewer and fewer people. The runner-up is my fellow-townsman, and I went home.

I'm the only one left in the dormitory who hasn't gone to review in recent days.

The review state has not been very good.

Can only look at extracurricular learning Python, machine learning, data mining.

Related books to accumulate knowledge for future data analysis

Today I will tell you about our class.

Class 2016 Statistics

Our class comes from different places.

The place where the red dot is the source.

Among them, Henan has the largest number of students.

In the twinkling of an eye, I was in the senior year, and the time to stay at school was running out.

First of all, we need to get the text data of the QQ group chat, and the crawler can crawl the web page data very well. the general crawling data flow is as follows

It is divided into four processes: website request, camouflage, parsing and storage.

A more detailed crawling process is as follows

Some rules need to be added

However, the text data of this article

I exported it from the background of the QQ computer.

The current learning of web crawlers

I only know how to climb Douban film review, book review and Taobao price.

When the specific study is mature,

Send a tweet from a web crawler

Please look forward to it.

After exporting text data

Write programs, debug code, do visual analysis

The detailed code is as follows

# QQ group chat data analysis code import reimport datetimeimport seaborn as snsimport matplotlib.pyplot as pltimport jiebafrom wordcloud import WordCloud, STOPWORDSfrom scipy.misc import imread# date def get_date (data): # date dates = re.findall (r'\ d {4} -\ d {2} -\ d {2}' Data) # day days = [date [- 2:] for date in dates] plt.subplot (221) sns.countplot (days) plt.title ('Days') # days of the week weekdays = [datetime.date (date [: 4]), int (date [5:7]) Int (date [- 2:]). Isocalendar () [- 1] for date in dates] plt.subplot (222) sns.countplot (weekdays) plt.title ('WeekDays') # time def get_time (data): times = re.findall (r'\ d {2}:\ d {2}:\ d {2}', data) # hours hours = [time [: 2] for time in times] plt.subplot (223) sns.countplot (hours Order= ['06,'07,'08,'09,'10,'11,'12,'13,'14,'15,'16,'17, 18, 19, 20, 21, 22, 23, 00, 01, 02, 03, 04 Plt.title ('Hours') code demo: # words def get_wordclound (text_data): word_list = [".join (jieba.cut (sentence)) for sentence in text_data] new_text =' .join (word_list) pic_path = 'QQ.jpg' mang_mask = imread (pic_path) plt.subplot (224) wordcloud = WordCloud (background_color=" white ") Font_path='/home/shen/Downloads/fonts/msyh.ttc', mask=mang_mask, stopwords=STOPWORDS) .generate (new_text) plt.imshow (wordcloud) plt.axis ("off") # content and words def get_content (data): pa = re.compile (r'\ d {4} -\ d {2} -\ d {2}. *?\ (\ d +\)\ n (. *?)\ n\ n' Re.DOTALL) content = re.findall (pa, data) get_wordclound (content) def run (): filename = 'New text document .txt' with open (filename) as f: data = f.read () get_date (data) get_time (data) get_content (data) plt.show ()

After making the text visual speech diagram, the following conclusions can be drawn.

In the group chat of 180 classes from January 1 to January 31, 2018

January 2 is the day with the most group chats.

Do more group chats on Tuesdays every week.

The number of group chat is the most at 16:00 every day.

Make a word cloud map to find

"all members" appear the most frequently.

On how to use Python statistics class 180 QQ group chat text visualization analysis questions shared here, I hope the above content can be of some help to you, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report