-1

I have recently started with Python in Power BI and I am a noob in it.

through power query, I have imported some columns from an Excel file into the power query and all of the fields are dates and put in the values area.

in the Python code, I tried to bring these fields into a DataFrame named required_data so I can draw my visual but I got the following error what should I do to import all the fields of the mydata on the right into the required_data DataFrame so the rest of the code runs smoothly and I can publish my visual enter image description here

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • 1
    Please read the documentation for [`pandas.DataFrame`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html), [Reading an Excel file in python using pandas](https://stackoverflow.com/q/17063458/7758804) – Trenton McKinney May 15 '23 at 19:48
  • In the documentation, everything is entered as literal. I need to use what I imported with the power query. There is no use in writing the name of columns as keys and typing that many dates as literals one by one as values – user18884753 May 15 '23 at 19:52
  • Your dataframe creation code makes no reference to the object created by **I have imported some columns from an Excel file into the power query and all of the fields are dates and put in the values area.** – Trenton McKinney May 15 '23 at 19:54
  • sorry, I did not understand your point. would you please provide at least one line of code so I can see what you mean? I can not reference the mydata at all – user18884753 May 15 '23 at 19:58

1 Answers1

0

The data frame has already been created for you and you can reference it using the variable dataset, eg

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: 

# dataset = pandas.DataFrame(day, sex, smoker, time)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:

import seaborn as sns
import matplotlib.pyplot as plt

sns.swarmplot(x="day",y="tip percent",data = dataset)

plt.show()
David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67