Big data modeling beginner question bank and answerHere are some questions and answers for beginner big data modeling:
** 1. Entry and exit model related questions **
1. ** Title **: In the entry-exit model, to filter out people from Southeast Asia, you can filter the "From Country Code" field and set multiple filtering conditions according to the country. What is the relationship between the multiple filtering conditions?
- [Answer: Logically.]
** 2. Panda related questions **
1. ** Question **: Which of the following methods can be used to write to a dsv file in pandas?
- ** Answer **: to_dsv ().
** 3. NumPy module related questions **
1. ** Question **: In NumPy, which of the following functions is not an arithmetic function?
- ** Answer **: Hypo2 (This should be hypot, assuming the original data was written incorrectly).
** 4. Random Array Generation Questions **
1. [Question **: Which of the following functions can generate a random array with a specified range?]
- ** Answer **: randint().
** 5. Questions related to primary key creation **
1. [Question: Is there a way to create a primary key?]
- ** Answer **: 3.
** 6. Python built-in function related questions **
1. ** Title **: Python's built-in function () can return the number of elements in a list, tuple, dictionary, set, string, and range object?
- ** Answer **: len.
** 7. Questions related to deleting data table records **
1. [Question **: Which of the following is used to delete a record in the data table?]
- ** Answer **: STOP (Assuming that the source data refers to the STOP statement in the database used to delete records, although the source data description is not complete and accurate).
"A Short History of the Future: Legends of the Intelligent Era" was equally exciting. Everyone was welcome to click and read it!
How to save data to txt in pythonThere are two main ways to save data to txt-files in Python:
1. ** Use the open and write functions **: This function can be used when the data to be saved is of string type (string type) or byte-type (byte-type). For example, to save the data to a file named test.txt.(test is the data to be saved), you can use the following code:
```python
with open("test.txt", "w+") as my_file:
my_file.write(test)
```
However, this method could not directly store array data.
2. ** Using the np.save function **: It is suitable for saving array data. For example, to save the array test into a file named test.txt. You can use the following code:
```python
import numpy as np
np.save('test.txt', test, fmt='%d')
```
Here, fMT='%d' is the data saved format, saved as an integral number. If the data is not a string type and you want to save it using the first method, you need to convert it to a string type with str. If the data type is a binary-type, you need to add the following code at the beginning of the code:
```python
import sys
reload(sys)
sys.setdefaultencoding("utf - 8")
```
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
python saves data files as txtsThere are two main ways to save data files as txts in Python:
1. Use the open and write functions: where test.txt is the file file name to be saved, test is the data to be saved, it can be string type, can also be type, but this method can not save the array, array storage requires the second method below. For example:
```python
with open("test.txt", "w") as my_file:
my_file.write("This is the data to save")
```
2. Use the np.save function: where test.txt is the file file name to be saved, test is the array to be saved, fMT='%d' is the data save format, saved as an integral.
When the data is a string type, you can also use the following code to save it:
```python
with open("Top250.txt", "w+") as my_file:
for item in my_spider.datas:
my_file.write(item)
```
If the data is not a string type, then convert it to a string type with str. When the data type is a binary-type, you need to add the following code at the beginning of the code:
```python
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
```
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
How Python saves data as txtsIn Python, there are two main ways to save data as txt-files:
1. Using the open and write functions:
- If the data is of string type (String type) or of type Bytes, you can use this method. For example, if the data to be saved is test and the file to be saved is test.txt. You can write:
```python
with open('test.txt', 'w') as f:
f.write(test)
```
- However, this method could not directly save the array. If you wanted to save the array, you needed to use the second method below.
2. Using the np.save function:
- This method could be used when the data to be saved was an array. For example, the array to be saved is test, the file name to be saved is test.txt. The data is saved in the format of fMT = '%d'(saved as an integral). The sample code is as follows:
```python
import numpy as np
np.save('test.txt', test, fmt = '%d')
```
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
How can a real life graph story be used to analyze data?When it comes to a real life graph story of a person's weight loss journey (x - axis is weeks, y - axis is weight), analyzing the data from the graph helps in understanding the effectiveness of the diet and exercise plan. If the graph shows a continuous downward trend, it means the plan is working well. But if there are plateaus or upward trends, adjustments need to be made either in the diet or exercise routine.
How does python analyze txt data?The following are the general steps to use Python to analyze txt-data:
1. ** Reading files **:
- Use the `open` function to open the txt-file in the appropriate mode (such as `r'` for read-only mode). Then, you can use the `readlines` method to read each line of the file. This method will read the contents of the file line by line and return a list containing the contents of each line. For example:
```python
f_path = 'your_file_path.txt'
with open(f_path, 'r') as f:
lines = f.readlines()
```
- You can also use the `pandas` library (if the data structure is more organized and requires more powerful data analysis functions) to read the txt-file. For example:
```python
import pandas as pd
data = pd.read_dsv ('your_file_path.txt', sep='\t') #If the file is separated by tabs, sep is set to'\t'
```
2. ** Data Preprocessing **:
- If you are reading a number and want to use it as a value, you may need to use the `int()` function to convert the string to an integral number for an integral number, and the `float()` function to convert a floating-point number.
- If there were missing values, they needed to be dealt with accordingly. For example, if you use pandas, you can use the fillna method to fill in the missing values.
3. ** Data Analysis **:
- It could be analyzed according to the structure and requirements of the data. For example, if you want to calculate the average value of a column, you can use `pandas` to read the data and calculate it like this: `column_mean = data['column_name'].mean()`.
- If you analyze it according to your own logic, you can use the index to retrieve the desired data from the list of data read by `readlines`, set the judgment conditions according to the requirements, and then perform corresponding operations on the data that meets the conditions, such as re-writing a txt file or performing statistics calculations.
4. ** Outputting the result or further processing **:
- If you need to output the result to a file, you can use the `open` function to open the file in a suitable mode (such as `'w'` for write mode,`'a'` for add mode) and then write the result. For example:
```python
f_path = 'output_file.txt'
with open(f_path, 'w') as f:
f.write('Analysis result: ' + str.(result))
```
- If you want to perform more complicated operations, such as visualizing the analysis results (using libraries such as matplotlib) or further modeling, you can do it according to your specific needs.
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
Python crawling data saved in txt formatThere are several ways to save data in txt-format in Python:
1. Using the open and write functions:
- If you want to save string or byte-type data (but you can't directly save arrays), you can use this method. For example, the following code saves a string to the test.txt:
```python
test = "This is a test string"
with open('test.txt', 'w') as f:
f.write(test)
```
2. Using the np.save function:
- This method can be used to save array type data to a txt-file. For example, if there is an array to save:
```python
import numpy as np
test = np.array([1, 2, 3])
np.save('test.txt', test, fmt='%d')
```
3. When it comes to saving the data as a txt-file after data crawling, if you use the pandas library to read the data, for example, read the data from the dsv file and save it as a txt-file:
- Method 1: Store the data in the data frame into a txt-file (using the pandas library). If the data is read from a file called train_dataset.dsv., the code is as follows:
```python
import pandas as pd
data_train = pd.read_csv("train_dataset.csv", encoding='utf - 8',sep='|')
train_content = pd.DataFrame(data_train.content)
train_content.to_csv("train_content.txt",sep ="\t",index=False)
```
- Method 2: Save the string to a txt-file:
```python
# file=open("train_content.txt',"w") #" w "for writing" w+"for reading and writing
# file.write(train_content)
# file.close()
```
4. To save the crawled data in a specific format (such as saving the data as txy after serializing it):
- Save in JSon sequence (suitable for converting objects such as a dictionary into a JSon string and saving it to txttext):
```python
import json
data = {"name": "Alice", "age": 25}
json_data = json.dumps(data)
with open('data.txt', 'w') as f:
f.write(json_data)
```
- If you use Pickle to serialize (convert Python objects into a sequence of words, save them, and then de-serialize them when you read them):
```python
import pickle
data = {"name": "Alice", "age": 25}
serialized_data = pickle.dumps(data)
with open('data.txt', 'wb') as f:
f.write(serialized_data)
```
- Xml serializing (convert the data into an Xml element, serialize it into a string, and save it in txt):
```python
import xml.etree.ElementTree as ET
data = {"name": "Alice", "age": 25}
root = ET.Element("data")
for key, value in data.items():
child = ET.SubElement(root, key)
child.text = str(value)
xml_data = ET.tostring(root, encoding="utf - 8", method="xml")
with open('data.txt', 'w') as f:
f.write(xml_data.decode())
```
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
Is an ordinary graph a directed graph?Ordinary graph was not a directed graph, but a graph with only one node. The following information was related to the ordinary diagram:
###The definition of ordinary graph
- A trivial graph was a graph with only one node. It was a concept in graph theory. If graph G was a (1,0) graph, it was called a trivial graph, or a graph composed of an isolated point was called a trivial graph.
###The difference between ordinary graph and directed graph
- ** The existence of edges **: The characteristic of a trivial graph is that the set of edges is empty, that is, it does not contain any directed edges.
- ** Directional **: An important feature of a directed graph is that the edges have a clear direction. Since the ordinary graph only has one apex, there is no edge, so there is no direction.
Ordinary graphs were a special class of graphs. Although they were not common in graph theory, their definition and properties were helpful in understanding more complex graph structures.
The Extraordinary Ordinary Life novel is equally exciting. Everyone is welcome to click and read it!
Python big data collection and mining e-bookHere are some possible ways to find Python big data collection and mining e-books:
- You can enter "Python Big Data Collection and Mining e-book" in the search engine to check the relevant e-book resources in the search results. Some may be provided for free, and some may need to be purchased.
- Check online book platforms, such as Dangdang, Jingdong Books, and other online bookstores, and search for e-books related to Python Big Data Collection and Mining.
In addition, he could also check some open source e-book platforms to see if there were users sharing e-book resources on related topics, but he had to ensure the legitimacy and security of the resources.
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
It's neither an Eulerian graph nor a hamilton graphThe key to an Eulerian graph was to traverse all the edges without repeating them (an undirected graph with an Eulerian circuit was called an Eulerian graph, and a graph with an Eulerian path but no Eulerian circuit was called a semi-Eulerian graph). For an undirected graph, an Eulerian graph must be connected and have no odd degree vertexes, and a semi-Eulerian graph must be connected and have two odd degree vertexes (one of these two vertexes is the starting point and the other is the ending point). For a digraph, the in-degree and out-degree of each point must be equal to be an Eulerian graph. The Eulerian path of a digraph is the starting point degree-1, the ending point degree is 1, and the rest of the points are 0.
The key to a hamilton graph was to traverse all the vertexes without repeating them.
If a graph does not meet the criteria of the Eulerian graph, that is, the undirected graph is not connected or has an odd number of degrees,(For a directed graph, the corresponding conditions for in-degree and out-degree are not satisfied), and the requirements for a hamiltonian graph are not satisfied (There are many ways to determine a hamiltonian graph, such as satisfying certain dissimilarity conditions, but there is no simple and unified determination based on the degree of the vertexes like the Eulerian graph. However, the whole graph must be able to traverse all the vertexes without repeating), then this graph is neither an Eulerian graph nor a hamiltonian graph. For example, a graph that is disconnected and has a chaotic structure and cannot traverse all the vertexes is neither an Eulerian graph nor a Hamilonian graph.
The Extraordinary Ordinary Life novel is equally exciting. Everyone is welcome to click and read it!