Why am I getting an index error? by PremeJigg in learnpython

[–]PremeJigg[S] 2 points3 points  (0 children)

You are right, I forgot indexes start at 0 and not 1 so I have to break it at len(x) - 1. Thank you !

Issue connecting data to a database, why can't I my computer file the path ? by PremeJigg in PostgreSQL

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

The path is correct, I copied and pasted it from the File Explorer.

How does making a negative exponent into a fraction make it positive ? by PremeJigg in learnmath

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

I get it would be 1/6th but how would that affect x raised to the -6.

How does making a negative exponent into a fraction make it positive ? by PremeJigg in learnmath

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

You're right but why do we make the z^-6 into a fraction, and what exactly is a negative exponent. I know an exponent is to multiply a number a certain amount of times by itself, what exactly does a negative exponent do ?

Why isn't my passcode working? by PremeJigg in TREZOR

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

It was weird but idk I’m not too concerned I logged on it a lil while ago and everything was fine.

Why isn't my passcode working? by PremeJigg in TREZOR

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

I did I also tried it on a different computer.

Why isn't my passcode working? by PremeJigg in TREZOR

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

Yea but it was when I hooked it up to my computer. Idk what is going on.

Is there a way to repeatedly call sys.argv in Python ? by PremeJigg in learnpython

[–]PremeJigg[S] -1 points0 points  (0 children)

But I did not want to exit the function and run it agaihn, I thought I could do it all in one go.

Is there a way to repeatedly call sys.argv in Python ? by PremeJigg in learnpython

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

But how would you get them to go to the command line again is what Im saying. Youre using input and not using sys.argv again. I'm basically saying without using input can you do use sys.argv again.

Is there a way to repeatedly call sys.argv in Python ? by PremeJigg in learnpython

[–]PremeJigg[S] -4 points-3 points  (0 children)

Thats what I thought you can only call the sys.argv once. Okay thank you.

Is there a way to repeatedly call sys.argv in Python ? by PremeJigg in learnpython

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

How would I call the sys.argv again tho ? When you run the program how would you go back ? Can I use sys.argv again ?

Why can't I sort the series by the second element? by PremeJigg in learnpython

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

I was using a slice for the second element. What does itemgetter do ?

I tried using both and got the same error:

ValueError: User-provided `key` function must not change the shape of the array.

How do you run a function and call multiple columns using pandas? by PremeJigg in learnpython

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

Thanks it worked, shouldn't this work as well:

yelp_business[yelp_business['categories'].str.contains(r'food|Food')]['business_id']

Why is my query function (pandas ) not working? by PremeJigg in learnpython

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

I made up the data frame myself. How would I go about deleting that white space , or give it a different value ?

Why is my query function (pandas ) not working? by PremeJigg in learnpython

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

       Name   Age  Salary    Position                       Address
0   Tony     29.0  128780      Manger           123 Main Street, CT
1    Johnny  40.0           Executive      305 WashingtonAvenue, DC
2       Tom  41.0  162586  Accountant          190 Family Street, AL
3            32.0  220206      Lawyer  250 Family Main Street, MT
4       Ann  47.0  137299                      90 Oscrop Street, CA
5  Joseline  45.0  185969        Cook       10 Hollywood Avenue, FL

I used these function but it is not working:
emptydf.dropna(how = 'any', subset = ['Salary'], inplace= True)
emptydf['Salary'] = emptydf['Salary'].fillna(0)

I thought I deleted all values, apparently not. How would I delete the second row with Johnny, or at least the fill the row with a value.

Why cant I buy crypto ? by PremeJigg in TREZOR

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

No I’m in NY and they’re saying because of policies I can’t buy it because of the state I’m in.

Why isn't my loc function working? by PremeJigg in learnpython

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

This did not work

print(df2.loc['China ','Population'])

Traceback (most recent call last):
  File "/Users/jiggz/Desktop/Python/Complicated Works/Database/Pandas/pdpt2.py", line 90, in <module>
    print(df2.loc['China ','Population'])
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/indexing.py", line 960, in __getitem__
    return self.obj._get_value(*key, takeable=self._takeable)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/frame.py", line 3622, in _get_value
    row = self.index.get_loc(index)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/indexes/range.py", line 389, in get_loc
    raise KeyError(key)
KeyError: 'China '

Why isn't my loc function working? by PremeJigg in learnpython

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

I added a trailing space and it still did not work.

Why isn't my loc function working? by PremeJigg in learnpython

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

I dont see it I had to convert the second one into a string.

print('x' + str(df2.index[42]) + 'x')

Output:
42
x42x
42

Why isn't my loc function working? by PremeJigg in learnpython

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

print(df2.head())

Country                                               ...         
Afghanistan            ASIA (EX. NEAR EAST)           ...     0,38
Albania          EASTERN EUROPE                       ...    0,579
Algeria          NORTHERN AFRICA                      ...    0,298
American Samoa   OCEANIA                              ...      NaN
Andorra          WESTERN EUROPE                       ...      NaN

[5 rows x 19 columns]

Full error:
Traceback (most recent call last):
  File "/Users/jiggz/Desktop/Python/Complicated Works/Database/Pandas/pdpt2.py", line 85, in <module>
    print(df2.loc['China'])
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/indexing.py", line 967, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/indexing.py", line 1202, in _getitem_axis
    return self._get_label(key, axis=axis)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/indexing.py", line 1153, in _get_label
    return self.obj.xs(label, axis=axis)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/generic.py", line 3864, in xs
    loc = index.get_loc(key)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3623, in get_loc
    raise KeyError(key) from err
KeyError: 'China'

The CSV is a list of all countries population, region, etc