data science name error: in spyder using python - python

enter image description here
data science problem there is some error in my code please some one help with it. I have tried multiple times can anyone suggest what to doo

You have never defined a variable called churn.
I think you wanted to use the variable data, where you created the data frame.

Related

Transformation and structuring of Excel file in Python

I ask you to help with the solution of the problem.
I recently started learning Python, and I don't have enough experience to solve it yet.
It is necessary to write a python script that transforms an Excel spreadsheet into a flat view for further work and analytics.
Source table: input ex.xlsx
Example of expected result: out ex.xlsx
I will be very grateful for help!
enter image description here
enter image description here
Consider to find out more about pandas dataframe. We can then use pd.read_excel() and pd.read_csv() to read the data into memory and process the data using pandas.

How to access contents of a TLorentz vector using python code

I am using the uproot package in python to read a .root file, and I need to access the contents of pf. As you can see from the picture, I can easily access the content of vz (blue arrows). However, when accessing the contents of pf (red arrows), it gives me an error. Based on the middle column in the description table, I realize that they different objects. Nevertheless, my question is, how can I access the objects of pf? Your help will be greatly appreciated. Also, please let me know if you cannot access the image. enter image description here

name ImageList is not defined in kaggle website

I was practicing some project from Kaggle notebook which is machine learning related code. and i am facing problem at one part. the error is NameError: name 'ImageList' is not defined. the Kaggle notebook link is this and the cell link is this. How can i fix it.
If you are getting this error even after defining the ImageList, Run the default first cell in the kaggle or make sure that U have run all the cells.
Even I faced the same issue during my initial practice on kaggle.

Using Tenor API in Python for printing gifs

So, I am trying to print out gifs by using Tenor API.
I want it to only print one gif link but it prints out everything any Idea how to fix this?
Thank you.
https://i.stack.imgur.com/xf084.png
Sadly, I can not tell you the exact problem you are having, I replicated your code and used the official API Docs here
From what I can tell, this is one GIF just in a lot of different formats.
You can filter them like so:
print(top_8gifs['weburl'])
or
print(top_8gifs['results'][0])
EDIT: Looking at your .png (please embed it as code in the future) this should work for you, if you want the url:
print(top_8gifs[0]['url'])
A Python dict you can select using the key (like gifs['weburl'])
A Python list you have to select by index so gifs[0]
Using these techniques you can gather the data you need from that output.

Tensorflow Wide & Deep Example Not Working

I am trying to get the Wide & Deep tutorial working but the following line keeps giving me issues when copying and pasting the code from github and the website.
df_train["income_bracket"].apply(lambda x: ">50K" in x)).astype(int)
I get the below error
TypeError: argument of type 'float' is not iterable
I am not too familar with lamda functions but I think it is making a dummy variable so I tried that using
for i in range(len(df_train)):
if df_train.loc[i,'income_bracket']=='>50k':
df_train.loc[i,LABEL_COLUMN] =1
else:
df_train.loc[i,LABEL_COLUMN] =0
But got the error
TypeError: Expected binary or unicode string, got nan
How do I get this tutorial working?
EDIT:
first line of data and headers
lambda function is quite useful and simple. It won't create dummy variables.
I've noticed that you import the original data into a CSV file. Try not do that and just use the original downloading data that shown in tutorial code. I have successfully tried in this way.
But I also got the same problem when I change to other data sets for training. So I still hope someone can solve this problem in a deeper way
It's the issue of the data, or the code of TensorFlow. We have submit the issue about that in https://github.com/tensorflow/tensorflow/issues/4293
You can download the files manually and remove the broken lines. Then run with this command.
python ./wide_n_deep_tutorial.py --train_data /home/data/train_data --test_data /home/data/test_data

Categories

Resources