Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

marked_transform.py 683 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. # In[1]:
  4. import numpy as np
  5. import pandas as pd
  6. df = pd.read_csv("markup_data.csv")
  7. graph_act = pd.read_csv("actual_graph.csv")
  8. # In[4]:
  9. graph_act['good_names'] = graph_act.graph_vertex + '.' + graph_act.graph_vertex_subclass
  10. # In[5]:
  11. columns_names = list(graph_act['good_names'])
  12. columns_names.insert(0, "code_block")
  13. # In[7]:
  14. temp = np.zeros(shape=(df.shape[0],len(columns_names)), dtype='int')
  15. res = pd.DataFrame(temp, columns=columns_names)
  16. res.code_block = df.code_block
  17. for row in range(df.shape[0]):
  18. res[columns_names[df['graph_vertex_id'][row]]][row] = 1
  19. # In[8]:
  20. res.to_csv('markup_data.csv')
  21. # In[ ]:
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...