Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 063b468

Browse files
committed
Add files via upload
1 parent d4f967a commit 063b468

File tree

7 files changed

+142
-0
lines changed

7 files changed

+142
-0
lines changed

Week4/data.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
course python1
2+
course python2

Week4/data3.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

Week4/fisier.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# file = open('data.txt', 'r+')
2+
# file.write("Hello")
3+
# file.close()
4+
5+
# file=open('data3.txt','w')
6+
# try:
7+
# file.write('hello')
8+
# finally:
9+
# file.close()
10+
11+
# with open('data.txt', 'w') as file:
12+
# file.write('course python1\n course python2')
13+
14+
# with open('data.txt', 'r') as file:
15+
# for line in file.readlines():
16+
# print(line, 'line')
17+
18+
# with open('data.txt', 'r') as file:
19+
# for line in list(file):
20+
# print(line)
21+
22+
with open('data.txt', 'r') as file:
23+
while True:
24+
line = file.readline()
25+
26+
if not line:
27+
break
28+
print(line)

Week4/pandas_exe.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pandas
2+
3+
dataset = {
4+
'masini': ["BMW", "DACIA", "FORD"],
5+
"culoare": ["rosu", "negru", "gri"]
6+
}
7+
# variabila = pandas.DataFrame(dataset)
8+
# print(variabila)
9+
10+
# culori = ["rosu", "negru", "gri"]
11+
# variabila = pandas.Series(culori, index=['x', 'y', 'z'])
12+
# print(variabila[0])
13+
# print(variabila)
14+
# print(variabila["z"], variabila[2])
15+
16+
17+
# dataset = {"BMW": "ROSU", "DACIA": "NEGRU", "FORD": "GRI"}
18+
# variabila = pandas.Series(dataset, index=["DACIA","FORD"])
19+
# print(variabila)
20+
variabila = pandas.DataFrame(dataset,index=["producator1","producator2","producator3"])
21+
# print(variabila.loc[0])
22+
# print(variabila.loc[[0,2]])
23+
# print(variabila.loc["producator1"])
24+
print(pandas.options.display.max_rows)
25+

Week4/pandas_json.py

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# import pandas as pd
2+
#
3+
# data = {
4+
# "Duration": {
5+
# "0": 60,
6+
# "1": 60,
7+
# "2": 60,
8+
# "3": 45,
9+
# "4": 45,
10+
# "5": 60
11+
# },
12+
# "Pulse": {
13+
# "0": 110,
14+
# "1": 117,
15+
# "2": 103,
16+
# "3": 109,
17+
# "4": 117,
18+
# "5": 102
19+
# },
20+
# "Maxpulse": {
21+
# "0": 130,
22+
# "1": 145,
23+
# "2": 135,
24+
# "3": 175,
25+
# "4": 148,
26+
# "5": 127
27+
# },
28+
# "Calories": {
29+
# "0": 409,
30+
# "1": 479,
31+
# "2": 340,
32+
# "3": 282,
33+
# "4": 406,
34+
# "5": 300
35+
# }
36+
# }
37+
#
38+
# df = pd.DataFrame(data)
39+
# # print(df.tail(2))
40+
# # print(df.head(2))
41+
# print(df.info())
42+
import pandas
43+
df = pandas.read_csv('test.csv')
44+
# print(df)
45+
# for x in df.index:
46+
# print(df.loc[x, 'AL'])
47+
# print(df.corr())
48+
# print(df.describe())
49+
# print(df.mean())
50+
# import matplotlib.pyplot as mathplotvar
51+
# df.plot(kind="scatter", x='AT', y='BE')
52+
# df['AT'].plot(kind='hist')
53+
# mathplotvar.show()
54+
# print(df)
55+
df.fillna(0, inplace=True)
56+
# print(df)
57+
# print(df.fillna(0))
58+
# df['AL'].fillna(100, inplace=True)
59+
# print(df)
60+
# df.loc[7, 'AL'] = 45
61+
# print(df)
62+
df.replace(': ', 0, inplace=True)
63+
df.replace(':', 0, inplace=True)
64+
# print(df.transpose())
65+
print(df)
66+
df.to_csv('test1.csv')

Week4/test.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
,AL,AT,BA,BE,BG,CH,CY
2+
0,: ,75 ,: ,77 ,45 ,:
3+
1,,79 ,: ,78 ,51 ,:
4+
2,: ,81 ,: ,80 ,54 ,:
5+
3,: ,81 ,: ,83 ,57 ,91 ,69
6+
4,: ,82 ,: ,82 ,59 ,: ,71
7+
5,: ,85 ,: ,85 ,64 ,: ,74
8+
6,: ,89 ,: ,86 ,67 ,93 b,79
9+
7,84 ,90 ,69 ,87 ,72 ,: ,86
10+
7,84 ,90 ,69 ,87 ,72 ,: ,86

Week4/test1.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
,Unnamed: 0,AL,AT,BA,BE,BG,CH,CY
2+
0,0,0,75,0,77,45,0,0.0
3+
1,1,0,79,0,78,51,0,0.0
4+
2,2,0,81,0,80,54,0,0.0
5+
3,3,0,81,0,83,57,91 ,69.0
6+
4,4,0,82,0,82,59,0,71.0
7+
5,5,0,85,0,85,64,0,74.0
8+
6,6,0,89,0,86,67,93 b,79.0
9+
7,7,84 ,90,69 ,87,72,0,86.0
10+
8,7,84 ,90,69 ,87,72,0,86.0

0 commit comments

Comments
 (0)