-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpandasReadFiles.py
More file actions
65 lines (54 loc) · 1.97 KB
/
Copy pathpandasReadFiles.py
File metadata and controls
65 lines (54 loc) · 1.97 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pandas as pd
import numpy as np
playersDF = pd.read_excel('C:\\Users\\u\\.spyder-py3\\DataD1\\Data TradeClients.xlsx')
#playersDF.sample(200).to_csv('MBPlayerSalaries200Sample22.csv') ### outputs a csv file
# Data TradeClients.xlsx
# \MLBPlayerSalaries.xlsx
print ('msg 4 Sample 10 ================ > ')
print (playersDF.sample(10))
print ('msg 1 INdex Values ================ > ')
print (playersDF.index.values)
print (playersDF.columns.values)
print (playersDF.iloc[0:2,:])
print ('number of rows', len(playersDF.index))
print ( playersDF.iloc[:,:].count() ) ## count rows of every solumn
count_row = playersDF.shape[0] # gives number of row count
print ( count_row)
r, c = playersDF.shape
total_rows=len(playersDF.axes[0])
total_cols=len(playersDF.axes[1])
print ( r , c , total_rows , total_cols )
count = 0
for row in playersDF.iterrows(): # returns every row as a tuple with 2 elements , a rownumber and the row as a series
print(row)
# print ( '---', len(row), type(row[1]), row[1] ) # row 1 is a series
# print ( '---', row[1]['Player'] , row[1]['Salary'] )
## print (b)
count += 1
if count > 10:
break
print ('msg 2 get the column headings ============ > ')
print ('msg 3 row 1 all columns =========== > ' ,playersDF.iloc[0:1,0:])
print ('0:1,0:1\n',playersDF.iloc[0:1,0:4])
count_col = playersDF.shape[1] # gives number of col count
print ( count_col)
#for in in range in playersDF:
# print (row)
df = pd.read_csv('C:\\Users\\u\\.spyder-py3\\DataD1\\MBPlayerSalaries200Sample2.csv')
#print ('msg 1 ')
#print (df.index.values)
#print ('msg 2')
#print('0:1,0:1\n',df.iloc[0:1,0:4])
#print ('msg 3')
#print('0:1,0:1\n',df.iloc[0:1,3:])
## True
#
#df1 = pd.DataFrame(
# {'name': ['Anastasia', np.nan, np.nan ],
# 'city': ['California', 'Los Angeles', np.nan]
# })
#
#print (df1)
print ( 'description ')
x = playersDF.describe()
print (x)