I have the following dataframe df with datetime index. I need to filter out the indexes where the following condition is met. It’s written in mql4 code which is where I’m converting this from, so bear with me. Using numbers as indexes so the bar2Open == ‘open’ is the value in the secon…
Tag: python
How to add a cursor() of a db connection to a sqlalchemy.orm session? “sqlalchemy.orm.exc.UnmappedInstanceError: Class ‘builtins.int’ is not mapped”
I am in a Ubuntu 22.04 Docker container with Python 3.10. I use these apt packages: I use the following Python packages: The sessionmaker parameter autoflush is set to True. I want to add a deletion and after that an insertion to a sqlalchemy.orm session so that I commit only when the two commands worked out …
How to Send Emails From Databricks
I have used the code from Send email from Databricks Notebook with attachment to attempt sending code from my Databricks Community edition: I have used the following code: As you can see the code is almost identical. However, when I run the code I get the following error: Is this error also because I’m …
how to format dates on x-axis in matplotlib?
I am trying to plot average temperatures from 1960 to 2021 for the month of December from time series data. my dataframe contains mean minimum and mean maximum temperatures, as for plotting i am trying as, for formatting dates on x-axis, i am trying as, but this gives me very messy x-axis ticks (all dates fro…
Begginer/ numpy where and copy
I am trying to copy values from one Field2 into Field1 if Field1 is null or NaN. I have tried below where statement as per documentation, but it cuts outliners instead of copyting the value. dataframe=np.where(dataframe[‘field1’].isnull(),np.copy(dataframe[‘field2’]),1) I have interpre…
How to generate random values for a predefined function?
I have a predefined function, for example this: How can I generate random values against it so I can plot the results of the function using matplotlib? Answer If you want to plot, don’t use random x values but rather a range. Also you should use numpy.exp that can take a vector as input and your y in th…
Calculating the semantic descriptor of a nested list
I am trying to calculate the semantic description of a nested list to turn it into a nested dictionary. First I got distinct_words, each word of it will be the keys of my final dictionary. EXPECTED OUTPUT: {‘i’: {‘am’: 3, ‘a’: 2, ‘sick’: 1, ‘man’: 3,…
Read file contents in python conditionally [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year. Improve this question I am trying to read one chromosome sequence from a genome file in python. Th…
Adding a header line to a scrollable canvas with weights
I’m trying get a list of .xlsm files from a folder, and generate a scrollable canvas from which the tabs needed for import can be selected manually using the check buttons (all having the same tab format e.g. tab1, tab2, tab3, tab4). The major issue I’m having is getting weights to work correctly …
How to change the x-axis and y-axis labels in plotly?
How can I change the x and y-axis labels in plotly because in matplotlib, I can simply use plt.xlabel but I am unable to do that in plotly. By using this code in a dataframe: I get this output: In this X and Y axis are labeled as X and Y how can I change the name of X and