官术网_书友最值得收藏!

An example of unstructured data – server logs

As an example of unstructured data, we have pulled some sample server logs from a public source and included them in a text document. We can take a glimpse of what this unstructured data looks like, so we can recognize it in the future:

# Import our data manipulation tool, Pandas
import pandas as pd
# Create a pandas DataFrame from some unstructured Server Logs
logs = pd.read_table('../data/server_logs.txt', header=None, names=['Info'])

# header=None, specifies that the first line of data is the first data point, not a column name
# names=['Info] is me setting the column name in our DataFrame for easier access

We created a DataFrame in pandas called logs that hold our server logs. To take a look, let's call the .head() method to look at the first few rows:

# Look at the first 5 rows
logs.head()

This will show us a table of the first 5 rows in our logs DataFrame as follows:

We can see in our logs that each row represents a single log and there is only a single column, the text of the log itself. Not exactly a characteristic or anything, just the raw log is taken directly from the server. This is a great example of unstructured data. Most often, data in the form of text is usually unstructured.

It is important to recognize that most unstructured data can be transformed into structured data through a few manipulations, but this is something that we will tackle in the next chapter.

Most of the data that we will be working on the book will be structured. That means that there will be a sense of rows and columns. Given this, we can start to look at the types of values in the cells of our tabular data.

主站蜘蛛池模板: 河曲县| 塘沽区| 灵山县| 宁南县| 阿拉善左旗| 简阳市| 华容县| 驻马店市| 监利县| 永泰县| 太谷县| 敦煌市| 合水县| 英山县| 寻乌县| 桑植县| 铁力市| 霸州市| 旬阳县| 临清市| 准格尔旗| 东丰县| 迁安市| 资阳市| 石楼县| 新宁县| 舟曲县| 宁德市| 红原县| 岐山县| 鸡西市| 凤翔县| 吕梁市| 博罗县| 关岭| 樟树市| 疏附县| 凌海市| 阿城市| 房山区| 苗栗县|