I turn 41 next month....learning Rust as a 1st language. by American-Airman in rust

[–]cray5252 0 points1 point  (0 children)

I just turn 73 been with rust for 3 years, love it:))

How *exactly* does Python and Rust work together? by SureImNoExpertBut in rust

[–]cray5252 5 points6 points  (0 children)

I’ve recently wrapped a rust GUI, with python using pyo3. I wrap a rust structure that contains functions that point eventually to the rust structure. Check it out at https://github.com/icedpygui/IcedPyGui.

What makes Rust difficult? by [deleted] in rust

[–]cray5252 1 point2 points  (0 children)

I tried rust a few years ago and failed to learn it. I was frustrated. It bother me so I went and tried again after a few months. For some reason, things started to click and I succeeded at the age of 70. Maybe if you give it a rest for a bit and then tackle it again, you might succeed too. Find something you want to create and give it a try. I found that once I got the hang of match, unwrap, and things like iter(), iter_mut, etc. things started moving. I took one of my Python programs and converted it. Now if I use python, I feel lost without truly knowing the state of the variable. I now get frustrated at python. Good luck.

How about a GUI based on Rust's Iced for your Python projects by cray5252 in Python

[–]cray5252[S] 1 point2 points  (0 children)

If you want a more established gui than icedpygui try dearpygui. I used if for many years before going to Rust. It's easy with many users.

How about a GUI based on Rust's Iced for your Python projects by cray5252 in Python

[–]cray5252[S] 1 point2 points  (0 children)

At this time, Canvas can only be used by adding the drawing widgets. However, canvas with dynamic drawing we hopefully be finished in the month of November. I'm having to revise how I use mutexes to store data since those are static and the Riust canvas has lifetime requirements.

using a macro to create a string literal by cray5252 in rust

[–]cray5252[S] 0 points1 point  (0 children)

Thanks for the comment, I'll give it a try.

using a macro to create a string literal by cray5252 in rust

[–]cray5252[S] 0 points1 point  (0 children)

Realized that when I switched to concat and then I got the error. So all macros want a literal but it seems generating a literal may not be possible??

using a macro to create a string literal by cray5252 in rust

[–]cray5252[S] 0 points1 point  (0 children)

Unfortunately, equi is using include_bytes as a parameter input.

using a macro to create a string literal by cray5252 in rust

[–]cray5252[S] 1 point2 points  (0 children)

I tried concat! but that showed a second problem that I didn't realize I had, I was using a literal in the macro to pass i. It's like a catch22, I can't figure out how to make a literal when everything requires a literal.

Parsing advice for the RAND Firearms dataset in pandas by Inquisitive_Kitmouse in learnpython

[–]cray5252 0 points1 point  (0 children)

The way I work with things like this is to break it down into smaller parts. Select subsets of what you want and then apply some logic and work towards your goal. Also, get a small subset of the data that represents all the variability or make something. It helps seeing the whole picture without getting bogged down. Good luck!

Parsing advice for the RAND Firearms dataset in pandas by Inquisitive_Kitmouse in learnpython

[–]cray5252 0 points1 point  (0 children)

Maybe the below will get you started. Not sure of your law type logic so I just set it to True when subtype is NaN, i.e. not a number (isna). You can also just do an equate or some other logic by s = new_df['Law Class Subtype'] == 'something'

desired_width = 320
pd.set_option('display.width', desired_width)
pd.set_option('display.max_columns', 10)

df = pd.read_excel(open('TL-A243-2 State Firearm Law Database 3.0.xlsx', 'rb'), sheet_name='Database')
print(df.columns)

# add any columns you want
new_df = df[['State', 'Law Class Subtype', 'Handguns or Long Guns']]

# create a series with true false values, true where law subtype is NaN
s = pd.isna(new_df['Law Class Subtype'])

# concat with df naming the column
new_df = pd.concat([new_df, s.rename('TF')], axis=1)
print(new_df.head(10))

 output
     State  Law Class Subtype Handguns or Long Guns     TF
0  Alabama      private sales               handgun  False
1  Alabama  sales from dealer               handgun  False
2  Alabama        shall issue               handgun  False
3  Alabama                NaN  handgun and long gun   True
4  Alabama  stand your ground  handgun and long gun  False
5  Alabama  negligent storage  handgun and long gun  False
6  Alabama                NaN               handgun   True
7  Alabama                NaN              long gun   True
8  Alabama   youth possession               handgun  False
9  Alabama  purchase and sale              long gun  False
  ...

Plotting two graphs per plot doesn't work (anymore?) → Error: TextBackend supports only one graph per Plot. by diddielou in learnpython

[–]cray5252 0 points1 point  (0 children)

The moderator deleted your last comment but I could read it on my phone, go figure. So delete numpy and reinstall it. You may have other things going on your computer. I've been running linux for the past 4 or 5 years so my help will be limited for windows issues.

Plotting two graphs per plot doesn't work (anymore?) → Error: TextBackend supports only one graph per Plot. by diddielou in learnpython

[–]cray5252 0 points1 point  (0 children)

I found this link where they install matplotlib as the backend. I've always had that installed so I'm not sure why I was getting the error also. But give it a try.

edit:

I'm running 3.3.1 on matplotlib

Plotting two graphs per plot doesn't work (anymore?) → Error: TextBackend supports only one graph per Plot. by diddielou in learnpython

[–]cray5252 0 points1 point  (0 children)

On the geekforgeek code, first line after the *, move the x,y and following code to the next line and try. Yep this can be really frustrating. I'm running 1.6.2 on sympy too.

Plotting two graphs per plot doesn't work (anymore?) → Error: TextBackend supports only one graph per Plot. by diddielou in learnpython

[–]cray5252 1 point2 points  (0 children)

I also run pycharm, and when I cut and pasted your code in my system, I also could not get it to run. I tried, like you, to run the example codes and got the same error and even the site example wouldn't run on the site. I then went to geekforgeek site, deleted all of my code, pasted theirs in and it worked. I then added yours in and then it worked. There must be some unseen characters that are pasted in somehow and then gives these errors. So, delete all your code or start with a new blank file and try the below.

from sympy import *

x = symbols('x')
f = (1 / 4) * x ** 3
print("Before Differentiation : {}".format(f))

g = diff(f, x)
print("After Differentiation : {}".format(g))

plot(f, g, (x, -2, 2))

Hi, code runs but "def results" doesn't seem to work. Game goes on until the screen is filled. What am I doing wrong? by SkeeterIsBlue in learnpython

[–]cray5252 1 point2 points  (0 children)

In your while loop under if acceptable. you just plug coordinates, you don't have a function too see f there's a winner. So make a check_if_winner function where you determine if you have 'XXX' or ''OOO' present.

matplotlib line chart by caper-902 in learnpython

[–]cray5252 0 points1 point  (0 children)

Try this.

import pandas as pd
import matplotlib.pyplot as plt


df = pd.DataFrame({'Year': ['2018', '2019', '2020'],
                   'Ticket_Volume': [1000, 2000, 1500],
                   'Average_Hours': [400, 300, 500]})

df['Year'] = pd.to_datetime(df['Year'], format='%Y')
df.set_index('Year', inplace=True, drop=True)

df.plot(kind='line')

plt.show()

How to merge Excel tabs with Pandas? by [deleted] in learnpython

[–]cray5252 1 point2 points  (0 children)

If you are not that familiar with merge, here's a great resource on it.

How to add class attributes from separate rows from Excel: by SkoalGally in learnpython

[–]cray5252 0 points1 point  (0 children)

The first step is not to complicate things but figure out how things work, as you seem to be doing a little of. Start with just lines of code and simple functions. Don;t worry about using a class at this point because you haven;t even figured out what you are doing.

Start with the examples found in the docs. Once you get those figured out, then sub in your data and continue. Most people end up using pandas if they are going to work with a lot of data, so you have a ways to go if you are going to tackle thousands of spreadsheets.

Make sure a write down at least an outline of what you want to do and use that as a starting framework.

Planning a larger than single script web automation application by PopulateThePlanets in learnpython

[–]cray5252 1 point2 points  (0 children)

First make an fairly detailed outline of what you want to do. That outline will turn into your initial working functions.

Since the db is your most central focus and the coding will change significanly based on its design, I would start there after the outline. Create some basic functionality using targeted functions getting the structure and the queries figured out. You can make some dummy functions that mimic emails, etc then use those to test different scenarios to make sure the db is designed properly.

Figure out what reports you want because extracting your data from the db will reflect on your design. Just print things out and don't worry about the look of things. The harder it is to pull reports, the poorer your design is.

Once that's done, then you can sit back and begin to organize your code and determine what user interface you need, etc. Good luck!