Can you please help me with some code? I need to make it as fast as possible (within two days :/ ), but I have some trouble making it. It is pretty simple, but I cannot catch my mistake in it.
I have a little problem looping over the csv file. I have a csv table and I need to go through all of the values in it and extract in separate lists the name of the column and the name of the row (which correspond to this value).
So in the very end I need to have 3 lists, which contain the same number of objects, because then I will need to make a graph using them.
My main goal is to graph the data. If you see any other ways to graph given table, can you please let me know.
When I tried to loop over the file, I get the message:
ValueError: too many values to unpack (expected 2)
Here is the code:
import pandas as pd
df = pd.DataFrame({'0.05 ml : 25 ml': {'7th generation': 0, 'Dawn Ultra': 0, 'Mrs Meyers': 1, 'Ultra Palmolive': 0}, '0.05 ml : 37.5 ml': {'7th generation': 0, 'Dawn Ultra': 3, 'Mrs Meyers': 0, 'Ultra Palmolive': 0}, '0.05 ml : 50 ml': {'7th generation': 0, 'Dawn Ultra': 0, 'Mrs Meyers': 0, 'Ultra Palmolive': 0}, '0.05 ml : 62.5 ml': {'7th generation': 0, 'Dawn Ultra': 0, 'Mrs Meyers': 4, 'Ultra Palmolive': 1}, '0.05 ml : 75 ml': {'7th generation': 0, 'Dawn Ultra': 1, 'Mrs Meyers': 1, 'Ultra Palmolive': 6}})
df.head()
detergent = []
concentration = []
num_colon = []
for (x, y) in df:
loc = df.iloc[x, y]
detergent.append(loc.index.values)
concentration.append(loc.columns.values)
num_colon.append(loc.values)
print(concentration)
print(detergent)
print(num_colon)
Output:
ValueError: too many values to unpack (expected 2)
The "Bio_sample_test.csv" looks like this: Bio_sample_test.csv
The table is pretty simple. And, as far as I understand, when I will be plotting it, I have to make a 3d graph?
Also, if you need this, here is the code which I plan to use to build the graph:
%matplotlib notebook
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(detergent, concentration, num_colon, c=values)
ax.set_xlabel("$detergent$")
ax.set_ylabel("$concentration$")
ax.set_zlabel("$num_colon$");
It would be also nice if somebody could help me to make the lists smooth, homogeneous. I mean, not that the final list is a list of arrays, but of independent values.