joelnazarene

python

Feb 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.63 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor
  4.  
  5. This is a temporary script file.
  6. """
  7.  
  8. import numpy as np
  9. import pandas as pd
  10. data = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,13],[12,14,15]])
  11. print(data)
  12. df= pd.DataFrame(data)
  13. df.columns = list("ABC")
  14. def function(col):
  15.     val=sum(col)/2
  16.     return(val)
  17.    
  18. print(function(df["A"]))
  19. =====================================================
  20. # -*- coding: utf-8 -*-
  21. """
  22. Created on Sun Feb 24 14:54:50 2019
  23.  
  24. @author: DEll
  25. """
  26.  
  27. import numpy as np
  28. import matplotlib.pyplot as plt
  29. x = np.arange(0,10)
  30. y=x^2
  31. plt.title("raph drawing")
  32. plt.xlabel("time")
  33. plt.ylabel("distance")
  34. plt.plot(x,y,'r')
  35. plt.plot(x,y,'>')
  36. #save in pdf format
  37. plt.savefig("time vs dist.pdf",format='pdf')
  38. ========================================================
  39. # -*- coding: utf-8 -*-
  40. """
  41. Created on Sun Feb 24 15:08:34 2019
  42.  
  43. @author: DEll
  44. """
  45.  
  46. import pandas as pd
  47. df = pd.read_csv(r"C:\Users\DEll\Downloads\HR_comma_sep.csv")
  48. ##
  49. #print(df.head(5))
  50. #print(df.tail(5))
  51. #print(df.info())
  52. #print(df.describe())
  53. #print(df[["satisfaction_level","salary","sales"]])
  54. df_copy=df.iloc[:500,[0,3,9]]
  55. df["col1"]=1
  56. df["new_salary"]=df["salary"].str.upper()+"_New"
  57. #print(df.describe())
  58. df_new = [(df["number_project"]>4)&(df["salary"]=="low")]
  59. df_new["number_project"].min()
  60.  
  61. =============================================================
  62. # -*- coding: utf-8 -*-
  63. """
  64. Created on Sun Feb 24 16:05:25 2019
  65.  
  66. @author: DEll
  67. """
  68.  
  69. import matplotlib.pyplot as plt:plt.rcdefaults()
  70. import numpy as nb
  71. import matplotlib.pyplot as plt
  72. objects=('python','c++','java','pearl','scala','lisb')
  73. y_pos=nb.arange(len(objects))
  74. performance=[10,8,6,4,2,1]
  75. plt.bar(y_pos,performance,align='center')
  76. plt.xticks(y_pos,objects)
  77. plt.ylabel("usage")
  78. plt.title('programming language function')
  79. plt.show()
  80.  
  81. =================================
  82. # -*- coding: utf-8 -*-
  83. """
  84. Created on Sun Feb 24 16:14:01 2019
  85.  
  86. @author: DEll
  87. """
  88.  
  89. import numpy as nb
  90. import matplotlib.pyplot as plt
  91. x=np.arange(0,3*np.pi,0.1)
  92. y=np.sin(x)
  93. plt.title('sine wave')
  94. plt.plot(x,y)
  95. plt.show()
  96. ==================================
  97. # -*- coding: utf-8 -*-
  98. """
  99. Created on Sun Feb 24 16:16:47 2019
  100.  
  101. @author: DEll
  102. """
  103.  
  104. import pandas as pd
  105. import numpy as np
  106. df =pd.DataFrame(np.random.rand(50,4),columns=['a','b','c','d'])
  107. df.plot.scatter(x='a',y='b')
  108. =============================
  109. # -*- coding: utf-8 -*-
  110. """
  111. Created on Sun Feb 24 16:20:07 2019
  112.  
  113. @author: DEll
  114. """
  115. import pandas as pd
  116. import numpy as np
  117. df=pd.DataFrame(np.random.rand(10,5),columns=['a','b','c','d','e'])
  118. df.plot.box(grid='True')
  119.  
  120. =======================================
Add Comment
Please, Sign In to add comment