0

enter image description here

I have written a very simple code that creates a pandas data frame. The issue is when I do my column naming ['X','Y'], my column heading X passes itself on to the column containing the index values. This only occurs when you run the code in jupyter environment, initiated in visual code by #%%. When you run the same code in the terminal the results are accurate. Shown in image below. Any ideas why?

#%%
import pandas as pd
from matplotlib import pyplot as plt
data_1 = {'X': [1.0,2.0,3.0], 'Y': [1.0,2.5,3.5]}
df_1 = pd.DataFrame(data_1)
print(df_1)

I have also tried other methods, but the result is the same

data_1 = [(1.0,1.0),(2.0,2.5),(3.0,3.5)]
df_1 = pd.DataFrame(data_1, columns = ['X','Y']

1 Answer 1

1

It's the default of the plugin and affects only visually... does not affect the functionallity

example

Sign up to request clarification or add additional context in comments.

2 Comments

Aight thanks. Well, I first thought it was producing two lines because its thinking x-axis to be index column and the other two columns as perhaps Y1, Y2. But it seems not to be the case. I guess I'll just have to remove that index column
I don't see this as a problem, but yes... if you remove the index you will "solve" that. Please, don't forget to mark the right answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.