Reputation: 31
This below code for streamlit Python program is working fine.
avg=s/c
k=s2.std(axis=1)
cv=(k/avg)
b6=b9.assign(average_value=avg,Std_Dev=k,Coff_Var=cv)
b8=b6.loc[b6['average_value'] > 1]
st.write(b8)
However , I wanted to plot a scatter plot chart of the variables and wrote the following lines
graph=pd.DataFrame(b6,columns=['Std_Dev','Coff_Var']) <------------This is line 61
plt.scatter(graph['Std_Dev'],graph['Coff_Var'])
st.pyplot()
I am not getting the results and its resulting in following error.
TypeError: Expected tuple, got str File "C:\Users\bahlrajesh23\datascience\data_charts.py", line 61, in graph=pd.DataFrame(b6,columns=['Std_Dev','Coff_Var'])
Upvotes: 0
Views: 2336
Reputation: 70
So I'm not sure what your variable b6
is, but it seems to be a string type and holds this path to a file: "C:\Users\bahlrajesh23\datascience\data_charts.py"
, not a tuple of data points.
If you're trying to create a pandas data frame from a file you need to pass in data or use pd.read_
and then the file type usually (csv is pd.read_csv
, excel is pd.read_excel
, etc... ). Then you can pass this a path to the file you want to use:
data = pd.read_csv("path/to/file/data.csv")
Not sure what plotting package your using? plt
could refer to matplotlib, altair, etc.. but I would generally recommend making a figure and axes handles that you can use to write to the screen (this is a matplotlib example):
import matplotlib.pyplot as plt
import streamlit as st
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.scatter(data)
st.write(fig)
Upvotes: 1