import pandas as pd
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
import matplotlib.pyplot as plt
from math import log,sqrt/
import numpy as np
import pandas as pd
#face detection.
data = pd.read_csv("data.csv")
data
import seaborn as sb
import matplotlib
import numpy as np
ef=pd.read_csv("weather.csv")
ef
#What is the size of the dataset?
len(ef)
22
#How many missing dewpoints are in the dataset?
len(ef[ef["Dewpoint"].isnull()])
1
#How many missing Rainfall are there?
len(ef[ef["Rainfall"].isnull()])
1
#Remove the rainfall row containing missing values.
ef[ef["Rainfall"].isnull()].drop()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-739dad1e5ebd> in <module>
1 #Remove the rainfall row containing missing values.
----> 2 ef[ef["Rainfall"].isnull()].drop()
~\Anaconda3\lib\site-packages\pandas\core\frame.py in drop(self, labels, axis, index, columns, level, inplace, errors)
3938 index=index, columns=columns,
3939 level=level, inplace=inplace,
-> 3940 errors=errors)
3941
3942 @rewrite_axis_style_signature('mapper', [('copy', True),
~\Anaconda3\lib\site-packages\pandas\core\generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)
3771 axes, _ = self._construct_axes_from_arguments((index, columns), {})
3772 else:
-> 3773 raise ValueError("Need to specify at least one of 'labels', "
3774 "'index' or 'columns'")
3775
ValueError: Need to specify at least one of 'labels', 'index' or 'columns'
#Replace the dewpoint row containing the missing value by the mean of the dewpoint column.
j=ef["Dewpoint"].mean()
ef[ef["Dewpoint"].isnull()]=j
ef
ef["Rainfall"].sort_values()
4 34.000000
19 56.095238
12 81.000000
0 83.000000
2 83.000000
3 84.000000
13 86.000000
11 86.000000
8 86.000000
5 87.000000
1 89.000000
9 90.000000
20 90.000000
14 91.000000
7 93.000000
15 93.000000
18 93.000000
16 94.000000
17 96.000000
10 97.000000
21 97.000000
6 NaN
Name: Rainfall, dtype: float64
#Sort and print the dataset according to the dewpoint column
ef["Dewpoint"].sort_values()
20 47.000000
0 50.000000
1 50.000000
4 50.000000
2 52.000000
17 52.000000
7 52.000000
10 53.000000
3 53.000000
5 54.000000
9 55.000000
8 56.000000
12 56.000000
19 56.095238
11 58.000000
13 58.000000
21 58.000000
18 60.000000
6 60.000000
15 65.000000
14 69.000000
16 70.000000
Name: Dewpoint, dtype: float64
#What is the mean of rainfall?
ef["Rainfall"].mean()
85.19501133786848
#What is the standard deviation of dewpoint?
for e in ef:
p=(ef["Rainfall"]-ef["Rainfall"].mean())**2
j=p.sum()
i=0
k=0
while(i>=j):
if(j%i==0):
k=j%i+k
i=i+1
print(k)
0
#Plot the dataset rainfall as axis
sb.scatterplot("Rainfall","Dewpoint",data=ef)
<matplotlib.axes._subplots.AxesSubplot at 0xaec2df25f8>
#Can you make any conclusion related to the plot?
s='''The rain falls values Greater than 80, the Due points Vary frequently,
The Due point Go on Increasing for the increased value of Rainfall'''
data.head()
t=data["SALES"].shape[0]
ti,tsi=list(),list()
for i in range(data.shape[0]):
if np.random.uniform(0,1)<0.75:
ti+=[i]
else:
tsi+=[i]
td=data.loc[ti]
ttd=data.loc[tsi]
td.head()
t=data["SALES"].shape[0]
spam_words=' '.join(list(data[data["ORDERNUMBER"]==0]["SALES"]))
spam_wc=WordCloud(width=512,height=512).generate(spam_words)
plt.figure(figsize=(10,8),facecolor='k')
plt.imshow(spam_wc)
plt.axis('off')
plt.tight.layout(pad=0)
plt.show()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-88-49e1eb4a5155> in <module>
1 spam_words=' '.join(list(data[data["ORDERNUMBER"]==0]["SALES"]))
----> 2 spam_wc=WordCloud(width=512,height=512).generate(spam_words)
3 plt.figure(figsize=(10,8),facecolor='k')
4 plt.imshow(spam_wc)
5 plt.axis('off')
NameError: name 'WordCloud' is not defined
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
~\Anaconda3\lib\imp.py in load_module(name, file, filename, details)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
~\Anaconda3\lib\imp.py in load_dynamic(name, path, file)
341 name=name, loader=loader, origin=path)
--> 342 return _load(spec)
343
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-89-d6579f534729> in <module>
----> 1 import tensorflow
~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
26
27 # pylint: disable=g-bad-import-order
---> 28 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
29 from tensorflow.python.tools import module_util as _module_util
30
~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\SIBANI\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\SIBANI\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\SIBANI\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\SIBANI\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\SIBANI\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.