I have been trying to create a Vincent time series line plot. My code is as follows:
#!/usr/bin/env python
import pandas as pd
import numpy as np
import vincent
#test data
df2 = pd.DataFrame({ 'A' : 1., 'B' : pd.Timestamp('20130102'),'C' : pd.Series(1,index=list(range(4)),dtype='float32'),'D' : np.array([3] * 4,dtype='int32'), 'E' : pd.Categorical(["test","train","test","train"]), 'F' : 'foo' })
vis = vincent.Line(df2) # test
vis.axis_titles(x='Time', y='Freq')
vis.legend(title='Words')
vis.to_json('chart.json')
vis.display()
I get no output (no display or chart.json created) or any errors. The other similar problems on here are due to Ipython notebook or Canopy issues, for example this; I am not using Ipython, notebook or Canopy. My question is: why is there no json created?
EDIT: OK maybe I am using Ipython without knowing it! I get this output:
<IPython.core.display.HTML at 0x7f980791e2d0>
However adding vis.core.initialize_notebook()from this solution does not help.
It was an issue with Eclipse. My working directory was for some reason set to a subdirectory where the json file WAS being created. I post this in case someone else is as stupid as me.
EDIT: I added the Eclipse tag. Should have been there in the beginning.
Related
I'm using Python 3.8.13 and Pandas 1.4.1 on Spyder 4.1.5.
I have no problem reading the dataframe into memory, but when I try to open the dataframe for viewing in the variable explorer I get the following:
"Spyder was unable to retrieve the value of this variable from the console. The error message was: Can't get attribute '_unpickle_block' on".
This is regardless of size (e.g. if I create a variable containing just the head of the dataset, the issue persists). Not sure why this specific error is showing as I don't believe I'm using a pickled object at any point.
I've confirmed that I can open the dataframe when using a Python 3.9 env with Spyder 5.1.5, but I need to use the former specs given they're locked in on a virtual machine. Here's my code as of now (very straightforward):
import pandas as pd
import numpy as np
filepath = "../../../projects2/"
df = pd.read_parquet(filepath + "hmda/lar/parquet/hmda_lar_2017.parquet")
I just started learning python about a week ago and I am using VS code.
I am trying to run the following code:
import pandas as pd
df = pd.read_csv('ClassMarks.csv')
pd.set_option('display.max_rows', 85)
df['Final Marks'] = df['CPQ']+df['HW']+df['Tutorials']+df['Tests']
print(df)
in the Output terminal it gives:
File "/Users/User1/Desktop/test", line 1, in <module>
import pandas as pd
ImportError: No module named pandas
while the Terminal gives me the result table I expect, with no errors.
Does anyone knows what is happening or how to fix it?
Thanks in advance!
Edit:
The problem I had was, that my Output window was using python 2.7.16 as default. To change it to python 3.8.2, I found the answer in this video:
https://www.youtube.com/watch?v=06I63_p-2A4,
starting from min 43:00.
I hope this helps others!
The problem I had was, that my Output window was using python 2.7.16 as default. To change it to python 3.8.2, I found the answer in this video: https://www.youtube.com/watch?v=06I63_p-2A4, starting from min 43:00.
I hope this helps others!
I want to import excel data in jupyter notebook,in the python 3.7, but I got the following errors, can anyone explain to me the solution of the problem awaiting for your kind response.
Make sure your path is correct for the excel file. Also, pay attention to slash '/' It is NOT '\'.
import pandas as pd
import os
my_path = 'C:/Users/user/Desktop/2nd Semester Research Topic'
df = pd.read_excel(os.path.join(my_path,'com.xlsx'))
Complete noob here. I've been trying the following instructions to access a data set on Kaggle and to read the first 5 rows.
https://towardsdatascience.com/simple-and-multiple-linear-regression-with-python-c9ab422ec29c
I'm using spyder and when I run the following code, I only obtain a runfile wdir= comment in the console
Following is the Code:
import pandas as pd
df=pd.read_csv('weight-height.csv')
df.head(5)
Output:
Code and Console Output
The medium post is probably using jupyter notebooks which will take the last line and put it as formatted output in a cell below it without a print. In a regular python script / idle or other IDEs, you need to actually use the print function to print to the terminal/console.
import pandas as pd
df = pd.read_csv('weight-height.csv')
print(df.head(5))
I am doing some the Learning Data Science with Python on Common Lounge website. One of the first problems is to load a csv file and print row 5. My data loads and I can print the whole array but when I try to print just one row I get the error "Backend MacOSX is interactive backend. Turning interactive mode on." What does this mean and how can I fix it? I'm using python3.
This also pops up on the side of Visual Studio Code:
"Unable to open 'hashtable_class_helper.pxi': File not found (file:///Users/a0015/Desktop/Programming/Commom_Lounge/pandas/_libs/hashtable_class_helper.pxi)."
Here is the whole code I have, the error is from the print(dataSet[5,2]) line.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataSet = pd.read_csv('/Users/a0015/Desktop/Programming/Commom_Lounge/diabetes.csv')
print(dataSet)
print(np.shape(dataSet))
print(dataSet[5,2])
Thanks for any help