Welcome to the Simplilearn Community

Want to join the rest of our members? Sign up right away!

Sign Up

DS with Python | Vigneshwar | Sept 14 - Oct 02 (2020)

@Vigneshwar, I am unable to visualize p and alpha values in a chi square test. can you provide any link where each value is shown as how it is derived or show a problem and explain these terms by solving the question?
 

Vigneshwar V

Customer
Customer

_78787

New Member
upload_2020-9-17_22-23-11.png
@Vignesh I have a valid list and performed map operation to get squared list, I am iterating to access the element, as you see the image.. but when I re-execute the same code as in 99 in 100th cell, I do not get output on running the 100th cell and neither executing 99th cell for second time.. why is it so?
 

Vigneshwar V

Customer
Customer
View attachment 11529
@Vignesh I have a valid list and performed map operation to get squared list, I am iterating to access the element, as you see the image.. but when I re-execute the same code as in 99 in 100th cell, I do not get output on running the 100th cell and neither executing 99th cell for second time.. why is it so?
Can you provide your previous code snippets as well? I need to understand what is stored in squared_list ? If possible, please attach the html file of the notebook with this thread. Thank you
 
var = dataframe[dataframe.drop('Score6',axis=1)]

I tried to capture the dropped column from our example as suggested by you but it did not work and getting teh below error. Can you provide the exact code?


---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-61-37ce00870538> in <module>
----> 1var = dataframe[dataframe.drop('Score6',axis=1)]

~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2785 # Do we have a (boolean) DataFrame?
2786 if isinstance(key, DataFrame):
-> 2787return self.where(key)
2788
2789 # Do we have a (boolean) 1d indexer?

~\anaconda3\lib\site-packages\pandas\core\generic.py in where(self, cond, other, inplace, axis, level, errors, try_cast)
8919 other = com.apply_if_callable(other, self)
8920 return self._where(
-> 8921cond, other, inplace, axis, level, errors=errors, try_cast=try_cast
8922 )
8923

~\anaconda3\lib\site-packages\pandas\core\generic.py in _where(self, cond, other, inplace, axis, level, errors, try_cast)
8677 for dt in cond.dtypes:
8678 if not is_bool_dtype(dt):
-> 8679raise ValueError(msg.format(dtype=dt))
8680
8681 cond = -cond if inplace else cond

ValueError: Boolean array expected for the condition, not float64
 

Vigneshwar V

Customer
Customer
var = dataframe[dataframe.drop('Score6',axis=1)]

I tried to capture the dropped column from our example as suggested by you but it did not work and getting teh below error. Can you provide the exact code?


---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-61-37ce00870538> in <module>
----> 1var = dataframe[dataframe.drop('Score6',axis=1)]

~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2785 # Do we have a (boolean) DataFrame?
2786 if isinstance(key, DataFrame):
-> 2787return self.where(key)
2788
2789 # Do we have a (boolean) 1d indexer?

~\anaconda3\lib\site-packages\pandas\core\generic.py in where(self, cond, other, inplace, axis, level, errors, try_cast)
8919 other = com.apply_if_callable(other, self)
8920 return self._where(
-> 8921cond, other, inplace, axis, level, errors=errors, try_cast=try_cast
8922 )
8923

~\anaconda3\lib\site-packages\pandas\core\generic.py in _where(self, cond, other, inplace, axis, level, errors, try_cast)
8677 for dt in cond.dtypes:
8678 if not is_bool_dtype(dt):
-> 8679raise ValueError(msg.format(dtype=dt))
8680
8681 cond = -cond if inplace else cond

ValueError: Boolean array expected for the condition, not float64
Hi Akhilesh, the pandas drop function will not be accepting conditions for dropping as we can specify only the labels and the axis by which we can remove columns or rows. If you want to capture the dropped column separately in a variable, create a dataframe/series variable and store only the column which you want to retain and then apply the drop function.
 
When we were running boxplot or scatter plot the output showed <matplotlib.axes._subplots.AxesSubplot at 0x1be5143f288> instead of AxesSubplot as shown in your program. Can you let us know why it is so?

In - sns.boxplot(sample)
Out - <matplotlib.axes._subplots.AxesSubplot at 0x1be5143f288>
 

_84921

New Member
Hi Vignehswar,

This is saravanakumar from DS batch.

i am using the local jupyter notebook and the below error is coming when we give a data frame to displot.

One hint: whenever we print the other plots, we are getting the object information starting with matplotlib whereas in the lms portal lab in which you are using for our classs its starts with axisplotlit.


upload_2020-9-23_22-49-23.png


Getting this erros while doing distplot
 
Last edited:

Anisha Baishya

New Member
Hello Vigneshwar,

Tried out a few of the data manipulation techniques on the dataPreprocessExample.csv as discussed in yesterday's class.

[P.S. I could not get much inference from the data :-( ]
 

Attachments

  • dataPreprocess.pdf
    122.4 KB · Views: 8
Hi Vignesh...I m getting error when i try to Bin....pls help to identify what is wrong in this code

top3_data = housing.Exterior1st.value_counts().head(3)
top3_data = list(top3_data.index)

Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-178-ff367fb579d7> in <module>
----> 1top3_data = list(top3_data.index)

TypeError: 'list' object is not callable
 
in my data set there is a column "name with no." like this ABC1234, DEF567,...so on.. then how i make a new column which contain only name and second column which contain only number.....so which function i use in here???
 
Hi Vignesh
I tried the train_test_splitup method...I m getting error when i do the model.fit() function. Please check attached PDF file on why i am getting the error

Thank you
Mohammed Shahid
 

Attachments

  • Train_test_splitup.pdf
    23 KB · Views: 7

Support Simplilearn(4685)

Moderator
Staff member
Alumni
Hi Vignesh
I tried the train_test_splitup method...I m getting error when i do the model.fit() function. Please check attached PDF file on why i am getting the error

Thank you
Mohammed Shahid
Hi Mohammed Shahidullah,

The code you have used to split the dataset into a train and test is wrong. Please refer to the corrected code below.

Code: x_train, x_test,y_train, y_test = train_test_split(features,target,test_size=0.2,random_state = 0)
This should fix the issue:
upload_2020-9-29_16-7-25.png

I hope that this helped.

Regards,
Team Simplilearn
 

Attachments

  • upload_2020-9-29_16-6-57.png
    upload_2020-9-29_16-6-57.png
    70.4 KB · Views: 8

Vigneshwar V

Customer
Customer
in my data set there is a column "name with no." like this ABC1234, DEF567,...so on.. then how i make a new column which contain only name and second column which contain only number.....so which function i use in here???

Hi Sourabh,
You have to play around with python codes on this to split text nd numbers using Regular expression or substring methods in python and make it like individual columns using pandas.

This might give you some idea how to go about for this scenario.
https://www.geeksforgeeks.org/python-splitting-text-and-number-in-string/
 

_89922

New Member
Hi Vignesh
Im sorry and please bear with me as im a medical doctor who is totally new to python.

I tried to import the data which is dat. file. Am I doing this correctly as i got output as attached.

Thank you
Dr Hafizuddin (Malaysia)
 

Attachments

  • Assesment1.PNG
    Assesment1.PNG
    29.1 KB · Views: 4
  • Assesment1a.PNG
    Assesment1a.PNG
    72.9 KB · Views: 3
Project -3
Question - Provide the trend chart for the number of complaints at monthly and daily granularity levels.

Am trying to convert the field "Date_month_year" like "DECEMBER 2015" . After convert the field I will use bar blot which month has high complaints. But am facing error to convert. Please see attached error.

from datetime import datetime

data=pd.to_datetime('Date_month_year', errors='raise',yearfirst=True, format="%B-%m")
 
---------------------------------------------------------------------------

TypeError Traceback (most recent call last)

~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)

431 try:

--> 432 values, tz = conversion.datetime_to_datetime64(arg)

433 return DatetimeIndex._simple_new(values, name=name, tz=tz)


pandas\_libs\tslibs\conversion.pyx in pandas._libs.tslibs.conversion.datetime_to_datetime64()


TypeError: Unrecognized value type: <class 'str'>


During handling of the above exception, another exception occurred:


ValueError Traceback (most recent call last)

<ipython-input-50-5cd030675fe8> in <module>

----> 1data=pd.to_datetime('Date_month_year', errors='raise',yearfirst=True, format="%B-%m")


~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache)

754 result = convert_listlike(arg, format)

755 else:

--> 756 result = convert_listlike(np.array([arg]), format)[0]

757

758 return result


~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)

433 return DatetimeIndex._simple_new(values, name=name, tz=tz)

434 except(ValueError, TypeError):

--> 435 raise e

436

437 if result isNone:


~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)

397 if result isNone:

398 try:

--> 399 result, timezones = array_strptime(

400 arg, format, exact=exact, errors=errors

401 )


pandas\_libs\tslibs\strptime.pyx in pandas._libs.tslibs.strptime.array_strptime()


ValueError: time data 'Date_month_year' does not match format '%B-%m' (match)
 

pavnesh9

Member
Capture.PNG Please help me with this I have uploaded the pdf file but they are asking me to upload HTML so do I upload the same file in the write up as well
 
Top